Create Excel Workbook from templates table

Hi everyone,

i have an Excel template stored in “WE Template” table and I want to create an Excel file, based on this template, whithout saving it to the disc. I.e. just in memory of computer.

Current code works like:

  1. Get template from table;

  2. Save to the disc;

  3. Open Excel template from disc and fill with the data.

// Get the template from source table:

WETemplate.GET(COPYSTR(CurrReport.OBJECTID(FALSE),8),WETemplate.Type::Excel);
WETemplate.CALCFIELDS(“Template Store”);

// Save to the disc

WETemplate.“Template Store”.EXPORT(FileName, FALSE);

// Create an Excel Workbook for work:
xlBook := xlApp.Workbooks._Open(FileName);

I want it to work like:

  1. Get template from table;

  2. Create Excel document, based on this template;

  3. Fill it with data, format;

  4. Export to PDF (xlBook.ExportAsFixedFormat(0,‘C:\test.pdf’):wink:

  5. Close Excel without saving.

Thansk for an Ideas

Hi Gennadiy and Welcome to the group !

This is going to be tough cookie because the Excel Automation (COM) object will require an existing file . You cannot pass a memory stream to it.

What do you want to achieve ?

G.

Good day,

thank you for reply.

I’m trying to Export report to PDF file. Now we have to do the following:

  1. Get Excel template, save to disc, fill with the data;

  2. Export this Excel report to PDF file (again saving to the disc) - xlBook.ExportAsFixedFormat(0,‘C:\test.pdf’);.

So as you may see there will be 2 files, saved to the disc: excel template and PDF file.

But i want to do it, without saving Excel file to the disc.

What about deleting the excel file after finishing the job?

Good idea,

please be so kind, give me some code for deleting :slight_smile:

I’m a new person in Programming Nav.

Try ERASE(’’);