Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
170
Export WinGrid to Excel with User Template File
posted

In this thread a user asked if it was possible to export to an Excel template. The answer provided indicated to use the overload for the UltraGridExcelExporter.Export() method  that allowed you to specify the WorkbookFormat. The API documentation isn't all that clear, but I surmise that these are pre-defined "templates". I'm actually wanting to know if it's possible to use a .xlt file as the format for the exported Excel file. For example, to have a certain Page Setup configured with custom headers and footers for the Excel file. If I am mistaken, please correct me, but based on what I see in the API documentation, there does not seem to be a way to do this (directly) with the UltraGridExcelExporter class. Is there a possibility to use a user-created template file when exporting to Excel?

Currently my planned workaround is to export as usual, then using ActiveX create a new workbook based on the template, and copy -> paste from the exported workbook to the "templated" workbook. Then I'd need to copy the color palette since the export also changes the color palette for Excel.

Parents
  • 44743
    posted

    The WorkbookFormat enumeration has various values indicating the file format for the saved workbook. One of these values is Excel97To2003Template, which is associated with an .xlt file. If you use that value and save to a file path with an .xlt extension, the exporter will create the template file.

Reply Children