Highlighted

Open an Excel template and add an sheet with CF 10

New Here ,
Sep 28, 2017

Copy link to clipboard

Copied

Hello,

I have a template containing some static pages saved on the server and I would like to add the dynamic pages to create another Excel file.

My problem is to open the template.

I Receive the following error: "The workbook already contains a sheet of this name"

How to do that?

The template name : "Template.xlsm"

My current code:

<cfset srcUploadedFile = application.settings.loadExcelDirectory & sepa & "Template.xlsm">

<!--- I would like to create an object "s" which is my Excel document --->

<cfspreadsheet action="read" src="#srcUploadedFile#" sheetname="History-version" name="s">

<!--- Create a new sheet and fill the new dynamic page --->

<cfset SpreadsheetCreateSheet (s, "Dynamic 1")>

<cfset SpreadsheetSetActiveSheet(s, "Dynamic 1")>

<cfset headerText = "" >

<cfset headerText = ListAppend(headerText, "Title 1") >

<cfset headerText = ListAppend(headerText, "Title 2") >

<cfset SpreadsheetAddRow(s, headerText)>

<!--- Create the new document --->

<cfheader name="content-disposition" value="attachment; filename=NewFile.xlsm">

<cfcontent type="application/msexcel" variable="#spreadsheetReadBinary(s)#" reset="true"> 

<cfabort>

Thank you in advance for your help

Best regards

Andre

Views

114

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Open an Excel template and add an sheet with CF 10

New Here ,
Sep 28, 2017

Copy link to clipboard

Copied

Hello,

I have a template containing some static pages saved on the server and I would like to add the dynamic pages to create another Excel file.

My problem is to open the template.

I Receive the following error: "The workbook already contains a sheet of this name"

How to do that?

The template name : "Template.xlsm"

My current code:

<cfset srcUploadedFile = application.settings.loadExcelDirectory & sepa & "Template.xlsm">

<!--- I would like to create an object "s" which is my Excel document --->

<cfspreadsheet action="read" src="#srcUploadedFile#" sheetname="History-version" name="s">

<!--- Create a new sheet and fill the new dynamic page --->

<cfset SpreadsheetCreateSheet (s, "Dynamic 1")>

<cfset SpreadsheetSetActiveSheet(s, "Dynamic 1")>

<cfset headerText = "" >

<cfset headerText = ListAppend(headerText, "Title 1") >

<cfset headerText = ListAppend(headerText, "Title 2") >

<cfset SpreadsheetAddRow(s, headerText)>

<!--- Create the new document --->

<cfheader name="content-disposition" value="attachment; filename=NewFile.xlsm">

<cfcontent type="application/msexcel" variable="#spreadsheetReadBinary(s)#" reset="true"> 

<cfabort>

Thank you in advance for your help

Best regards

Andre

Views

115

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 28, 2017 0

Have something to add?

Join the conversation