CFSpreadSheet - format column not formatting the entire column

别等时光非礼了梦想. 提交于 2019-12-11 11:28:41

问题


Using CF10 Standard to create a spreadsheet from a query. No matter what I've tried so far, the formatting for a specific column stops at row 32 (1 header row, 31 data), even though the entire sheet is populated to 186 rows.

<cfscript>
 dfStyle=StructNew();
 dfStyle.fgcolor="pale_blue";
 dfStyle.dataformat="mm/dd/yyyy";
 theSheet = SpreadSheetNew('mysheet');
 SpreadSheetAddRow(theSheet,'SID,FIRST,LAST,ADDRESS1,ADDRESS2,CITY,STATE,ZIP,EMAIL,ADDED,PID');
 SpreadSheetAddRows(theSheet,qry);
 SpreadSheetFormatColumn(theSheet,dfStyle,10);
</cfscript>

I'm trying to get a consistent mm/dd/yyyy format on the 'ADDED' column. Instead, I'm getting that through row 31, and then getting dates like 41937.56594 on the of the rows.

In the formula bar I show "10/20/2014 12:25:23 PM" as the first value and "41932.552037037" as the 2nd value.

If I format the date in the query (i.e. date_format(sp_add,'%c/%e/%Y') AS spadd) I do get a nice date format all the way down the column, but the blue still stops at row 32.

Here is the cfoutput of the anonymized query - top row is formatted, bottom row loses formatting (background color - formatting dates in query). I also dropped the ADDRESS2 column from the query for now.


回答1:


I'm not sure what the problem is, but try using the XML format option (the option to produce an xlsx file instead of the older style xls file). In your code add the "true" as a second argument to your spreadsheetnew() function call.

<cfscript>
 dfStyle=StructNew();
 dfStyle.fgcolor="pale_blue";
 dfStyle.dataformat="mm/dd/yyyy";

 theSheet = SpreadSheetNew('mysheet',TRUE);

 SpreadSheetAddRow(theSheet,'SID,FIRST,LAST,ADDRESS1,ADDRESS2,CITY,STATE,ZIP,EMAIL,ADDED,PID');
 SpreadSheetAddRows(theSheet,qry);
 SpreadSheetFormatColumn(theSheet,dfStyle,10);
</cfscript>

This will solve the problem - though we don't know why :)



来源:https://stackoverflow.com/questions/26657086/cfspreadsheet-format-column-not-formatting-the-entire-column

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!