Skip to content

Instantly share code, notes, and snippets.

@mickle00
Created November 23, 2012 22:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mickle00/4137588 to your computer and use it in GitHub Desktop.
Save mickle00/4137588 to your computer and use it in GitHub Desktop.
Hacky workaround to force newLine
<apex:page readOnly="true"
contentType="application/octet-stream#MyCsv.csv"
sidebar="false"
standardStylesheets="false"
showHeader="false"
cache="true"
expires="0">
<!--
This will create a newLine, but will insert an empty space in the first column of every row.
<apex:outputText value="Column 1,Column 2,Column 3"/>
&nbsp;<apex:outputText value="aVal1,aVal2,aVal3"/>
&nbsp;<apex:outputText value="bVal1,bVal2,bVal3"/>
&nbsp;<apex:outputText value="bVal1,bVal2,bVal3"/>
&nbsp;<apex:outputText value="bVal1,bVal2,bVal3"/>
&nbsp;<apex:outputText value="bVal1,bVal2,bVal3"/>
-->
<!--
Use a dummy "rowCount" column to still force a newline, but preserve the actual value (e.g., no uneccessary space)
and attempt to not lose too much value by having a somewhat not-useless column (debatable)
-->
<apex:variable value="{!1}" var="rowNum"/>
<apex:outputText value="Row,Column 1,Column 2,Column 3"/>
{!rowNum},<apex:outputText value="aVal1,aVal2,aVal3"/><apex:variable var="rowNum" value="{!rowNum+1}"/>
{!rowNum},<apex:outputText value="bVal1,bVal2,bVal3"/><apex:variable var="rowNum" value="{!rowNum+1}"/>
{!rowNum},<apex:outputText value="bVal1,bVal2,bVal3"/><apex:variable var="rowNum" value="{!rowNum+1}"/>
{!rowNum},<apex:outputText value="bVal1,bVal2,bVal3"/><apex:variable var="rowNum" value="{!rowNum+1}"/>
{!rowNum},<apex:outputText value="bVal1,bVal2,bVal3"/><apex:variable var="rowNum" value="{!rowNum+1}"/>
</apex:page>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment