D J
asked on
ColdFusion How do I set the cell padding when creating an excel spreadsheet?
How do I increase the cell padding (space between the text and the cell) for the whole excel document?
Increase the width of the column, if it's right justified add padding-right: style
ASKER
Can you give me an example?
The example depends on how you are coding it; can you post part of your code so I can see what you're doing and then I can help adjust it..
In excel, you can set the indent attribute for a cell.
e.g.
Range("A1").IndentLevel = 5
With coldfusion you can set the display attributes for a cell/rows/columns
e.g.
cellFormat = StructNew();
cellFormat.font = "Arial";
cellFormat.fontsize = "18";
cellFormat.color = "black";
cellFormat.alignment = "left";
cellFormat.verticalalignme nt = "vertical_top"
cellFormat.textwrap = "true";
cellFormat.fgcolor = "white";
cellFormat.indent=5;
SpreadsheetFormatcell( sheetObj, cellFormat, rowNum, colNum );
e.g.
Range("A1").IndentLevel = 5
With coldfusion you can set the display attributes for a cell/rows/columns
e.g.
cellFormat = StructNew();
cellFormat.font = "Arial";
cellFormat.fontsize = "18";
cellFormat.color = "black";
cellFormat.alignment = "left";
cellFormat.verticalalignme
cellFormat.textwrap = "true";
cellFormat.fgcolor = "white";
cellFormat.indent=5;
SpreadsheetFormatcell( sheetObj, cellFormat, rowNum, colNum );
ASKER
What property creates space above and below the text in a cell?
Is there one property to create space all around the text in a cell?
Here is my existing code:
<cfif structKeyExists(FORM, "export") AND structKeyExists(VARIABLES, "Results")>
<cfset sObj = SpreadsheetNew(#discipline 1#)>
<!--- add query parmas in 1st row and center align --->
<cfset columnsInQuery = listLen(results.columnList )>
<cfset SpreadsheetMergeCells(sObj , 1, 1, 1, columnsInQuery)>
<cfset SpreadSheetSetCellValue(sO bj, querySummary, 1, 1)>
<cfset SpreadsheetFormatRow(sObj, {alignment="center"}, 1)>
<!--- add record count in 2nd row and center align --->
<cfset SpreadsheetMergeCells(sObj , 2, 2, 1, columnsInQuery)>
<cfset SpreadSheetSetCellValue(sO bj, recordsSummary, 2, 1)>
<cfset SpreadsheetFormatRow(sObj, {alignment="center"}, 2)>
<!--- Create header row --->
<cfset SpreadsheetAddRow(sObj, "EQ,lian,S,Sp,Pro,Num,D,De scription, QTY,QTY2 ,UI,SN,Con,Date")>
<cfset SpreadsheetFormatRows(sObj , {bold=TRUE,fgcolor="grey_2 5_percent" ,fontsize= "12", alignment="center"}, "1-3")>
<cfset SpreadsheetFormatRow(sObj, {topborder="medium"}, 3)>
<cfset SpreadsheetAddRows(sObj, Results)>
<cfset SpreadsheetFormatColumns(s Obj, {fontsize="12",bottomborde r="medium" ,leftborde r="medium" ,rightbord er="medium "},"1-14") >
<cfset saveToFile = "C:\orders#createUUID()#.x ls">
<cfspreadsheet action="write" name="sObj" filename="#saveToFile#" overwrite="true">
<cfheader name="Content-Disposition" value="inline; filename=Orders.xls">
<cfcontent type="application/excel" file="#saveToFile#" deletefile="yes">
<!---- we're finished so exit --->
<cfabort />
</cfif>
Is there one property to create space all around the text in a cell?
Here is my existing code:
<cfif structKeyExists(FORM, "export") AND structKeyExists(VARIABLES,
<cfset sObj = SpreadsheetNew(#discipline
<!--- add query parmas in 1st row and center align --->
<cfset columnsInQuery = listLen(results.columnList
<cfset SpreadsheetMergeCells(sObj
<cfset SpreadSheetSetCellValue(sO
<cfset SpreadsheetFormatRow(sObj,
<!--- add record count in 2nd row and center align --->
<cfset SpreadsheetMergeCells(sObj
<cfset SpreadSheetSetCellValue(sO
<cfset SpreadsheetFormatRow(sObj,
<!--- Create header row --->
<cfset SpreadsheetAddRow(sObj, "EQ,lian,S,Sp,Pro,Num,D,De
<cfset SpreadsheetFormatRows(sObj
<cfset SpreadsheetFormatRow(sObj,
<cfset SpreadsheetAddRows(sObj, Results)>
<cfset SpreadsheetFormatColumns(s
<cfset saveToFile = "C:\orders#createUUID()#.x
<cfspreadsheet action="write" name="sObj" filename="#saveToFile#" overwrite="true">
<cfheader name="Content-Disposition"
<cfcontent type="application/excel" file="#saveToFile#" deletefile="yes">
<!---- we're finished so exit --->
<cfabort />
</cfif>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
How can I use SpreadsheetSetRowHeight for all rows?
The number of rows vary according to query results.
The number of rows vary according to query results.
excel vba : Range("A").RowHeight = 30;
Coldfusion Function:
SpreadsheetSetRowHeight
You can also try
rowFormat.rowheight
Coldfusion Function:
SpreadsheetSetRowHeight
You can also try
rowFormat.rowheight
> How can I use SpreadsheetSetRowHeight for all rows?
(No points)
As gdemaria mentioned, there's SpreadsheetSetRowHeight. But it doesn't accept a range. You must call it in a loop.
<cfset maxRow = Results.recordCount + (number of header rows)>
<cfloop from="1" to="#maxRow#" index="rowNum">
<cfset SpreadsheetSetRowHeight(sO bj, rowNum, (height you want))>
</cfloop>
(No points)
As gdemaria mentioned, there's SpreadsheetSetRowHeight. But it doesn't accept a range. You must call it in a loop.
<cfset maxRow = Results.recordCount + (number of header rows)>
<cfloop from="1" to="#maxRow#" index="rowNum">
<cfset SpreadsheetSetRowHeight(sO
</cfloop>
One more thing. I'm pretty sure Excel doesn't have the concept of cell padding like in html tables. AFAIK the best you can get is either change the row height (plus center align) like gdemaria suggested OR add indentation like pravinasar suggested. There is no setting to add padding on all sides.
ASKER
Thanks _agx_ the loop worked great!
I'm having a problem with text wrapping and column width.
I want to text wrap the third column header:
QTY REC to
QTY
REC
I tried using:
<cfset SpreadsheetFormatCell(sObj , {textwrap=true}, 2, 3)>
<cfset SpreadSheetSetColumnWidth( sObj, 3, 3)>
Without any effect.
I'm having a problem with text wrapping and column width.
I want to text wrap the third column header:
QTY REC to
QTY
REC
I tried using:
<cfset SpreadsheetFormatCell(sObj
<cfset SpreadSheetSetColumnWidth(
Without any effect.
You can have textwrap
cellFormat.textwrap = "true";
But this would ensure you have break at particular location.
You can force line breaks to appear in cell contents by
value= "Line 1" & chr(10) & "Line 2"
cellFormat.textwrap = "true";
But this would ensure you have break at particular location.
You can force line breaks to appear in cell contents by
value= "Line 1" & chr(10) & "Line 2"
ASKER
How do I utilize/format this line in my spreadsheet code?
value= "Line 1" & chr(10) & "Line 2"
<cfset value= "Line 1" & chr(10) & "Line 2"?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Big THANKS to everyone!
@DJPro - I think you accidentally omitted pravinasar's response as part of the answer. He mentioned using chr(10) to force a new line. (I just combined both of your answers into a working example.) If you want to reallocate, just use the "Request Attention" link in the original question and the mods can re-open it for you. Cheers!
It is weird
I put quite a bit of effort in explaining with cf functions
And I get zero
Have a nice year
I put quite a bit of effort in explaining with cf functions
And I get zero
Have a nice year