Forum Discussion

TomY's avatar
TomY
Occasional Contributor
15 years ago

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?


  • TomY's avatar
    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
  • 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.