• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Open an Excel template and add an sheet with CF 10

Explorer ,
Sep 28, 2017 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

176

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
community guidelines
no replies

Have something to add?

Join the conversation
Resources
Documentation