2013-01-16 82 views
0

我有一个查询,我想在Excel中的电子表格中输出。我想要以某种方式格式化一些单元格列,这是成千上万的分组格式和数字格式,因此可以在该行上进行总和,添加等操作,而无需进一步修改。导出到Excel并使用ColdFusion 10格式化单元格

我已经通读了文档,但它让我对如何首先输出到Excel有些困惑。

回答

3

我从评论开始,但它会更容易阅读作为答案。

你有什么试过的?你有没有读过CFSpreadsheet documentation?应该非常简单。 CFSpreadsheet标签的其中一个参数是'query'。为什么不从这个开始,看看它如何为你默认格式化列,看看需要调整什么。

这里是直接从被引用的文档页面所取的例子:

<cfquery name="courses" datasource="cfdocexamples"> 
    SELECT CORNUMBER, DEPT_ID, COURSE_ID, CORNAME 
    FROM COURSELIST 
</cfquery> 

<cfscript> 
    //Use an absolute path for the files. ---> 
    theDir=GetDirectoryFromPath(GetCurrentTemplatePath()); 
    theFile=theDir & "courses.xls"; 
    //Create an empty ColdFusion spreadsheet object. ---> 
    theSheet = SpreadsheetNew("CourseData"); 
    //Populate the object with a query. ---> 
    SpreadsheetAddRows(theSheet,courses); 
</cfscript> 

<!--- Write the sheet to a file ---> 
<cfspreadsheet action="write" filename="#theFile#" name="theSheet" sheetname="courses" overwrite=true> 

查看的文档SpreadsheetFormatColumnSpreadsheetFormatColumnsSpreadsheetFormatRowSpreadsheetFormatRows阅读有关格式化的特定细胞。

1

您只需使用cfspreadsheet标记创建文件,并且可以使用spreadsheetFormat*函数格式化单元格。您可以在Ray Camden's site找到如何执行此操作的示例。

相关问题