Skip to main content
Renand
Participant
November 24, 2010
Question

spreadsheet set createdate

  • November 24, 2010
  • 1 reply
  • 411 views

Hi, excuse my poor english.

I need some help with spreadsheet.

When I create a sheet with spreadsheetNew() function, the createdate information was an empty field.

I don't find how I can put this date by myself, of with a dedicaded function.

spreadsheetAddInfo() dont expose this possiblity..

Do you have an ideas ?

Thanks in advance.

This topic has been closed for replies.

1 reply

Inspiring
November 27, 2010

I could be wrong, but I do not think there is a documented way to add the date for .xls files. You can use the underlying POI object to add the date. Unfortunately it requires saving the file to disk twice. But it does work.  Edit:  You can probably do it in a single step. If you have access to createObject("java")


<!--- create a sample file --->
<cfset outPath = ExpandPath("./testFile.xls")>
<cfset sheet = SpreadsheetNew()>
<cfset spreadsheetSetCellValue(sheet, "foo", 1, 1)>
<cfset spreadsheetWrite(sheet, outPath, true)>

<!--- read file again. add the date. save it to disk --->
<cfset sheet = SpreadSheetRead(outPath)>
<cfset info = sheet.getWorkbook().getSummaryInformation()>
<cfset info.setCreateDateTime( now() )>
<cfset spreadsheetWrite(sheet, outPath, true)>

<!--- test results --->
<cfset sheet = SpreadSheetRead(outPath)>
<cfdump var="#SpreadsheetInfo(sheet)#" label="New Summary Information">