Ask a Question

Writing 2007 Excel File

TomY
Occasional Contributor

Writing 2007 Excel File

I am creating an excel file with test data and am using that for validation.



I have Office 2007 installed giving me a default 2007 format when I write my file.  When I go to read the file with Java, it has problems recognizing a 2007 Excel but not a 2003.  Is there an option to write the Excel in 2003?



...

  xclD       = Sys.OleObject("Excel.Application");

  workBkDarwin    = xclD.Workbooks.Add();

 

  workSheetEvent = workBkDarwin.Sheets.Add();

  workSheetEvent.Name = "Event";

  ...



When executing the OleObject or workbook, can I tell it to create in 2003 format?


3 REPLIES 3
YMinaev
Staff

Hi,



When saving your document, use the SaveAs method and specify the format you need.
------
Yuri
TestComplete Customer Care Engineer

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
TomY
Occasional Contributor

Looks like the second option is SaveAs is XlFileFormat  which designates the file format. 

How do we access the enumeration for the file format option? 



xcl      = Sys.OleObject("Excel.Application");

workb = xcl.Workbooks.Add();



...



// I tried

var ff = Sys.OleObject("Excel.XlFileFormat.xlAddIn");

workb.SaveAs("myWork.xcl",ff);

// But got an error that it could not find class.



Thanks
YMinaev
Staff

Hi,



In the MSDN article I referred to, there's a link to available XlFileFormat constants with their numeric values. You need to use numbers, not names constants, since they're not available outside Excel.
------
Yuri
TestComplete Customer Care Engineer

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: