user3365058
user3365058

Reputation: 19

How to export file to excel 2007+ in C#

I want to export the file as an xls to Excel 2007+, why it is always saved as an Excel 97-2003 File? what I do wrong?

this is the Row that saves the file:

xlWorkBook.SaveAs(TargetFolderText.Text + "\\" + TargetFIleText.Text + ".xls");

Upvotes: 1

Views: 386

Answers (1)

Max
Max

Reputation: 13338

Could you replace your code with:

xlWorkBook.SaveAs(TargetFolderText.Text + "\\" + TargetFIleText.Text + ".xlsx");

The xls extension is for Excel 2003 and earlier.
The xlsx extension is for Excel 2007 and later.
Use xlsm when using macro's in Excel sheet(2007 and later)

Article about the differences between XLS and XLSX

Upvotes: 1

Related Questions