Hi,
I am using filestream to open and save excel workbook.
Can someone tell me how to use FileFormatType to open an excel file properly?
I can use workbook.Open(docFile) and workbook.Save(docFile), but to use filestream,especially when save workbook with stream, I need to provide a proper fileformat.
say I have these excel files:
test97.xls, test2000.xls, testxp.xls,test2003.xls, and test2007.xlsx,
based on extension, I can tell test2007.xlsx need to use
FileFormatType.Excel2007Xlsx to open, but how about the rest files all with same extension, can I use default format to open and save all other xls file?
such as :
docFile will be any my test***.xls file,
fstream = new System.IO.FileStream(docFile, FileMode.Open);
workbook.Open(fstream, FileFormatType.Default);
and,
workbook.Save(docFile, FileFormatType.Default);
If this won't work, then what is right way to use fileformattype? Or is there anyway I can detect the excel version before try to open it?
Thanks
Chang