How to read excel application version from xls (Excel97) files? - c#

When using NPOI WorkbookFactory with a "modern" Excel file (*.xlsx) it produces an XSSFWorkbook, which contains the Excel-version:
xssfWorkbook.GetProperties().ExtendedProperties.AppVersion
This returns the Excel version number, e.g. "16.0300".
Is there a way to get this information for a HSSFWorkbook?
BTW: The name of the application is available in both classes:
hssfWorkbook.SummaryInformation.ApplicationName
xssfWorkbook.GetProperties().ExtendedProperties.Application
For MS Excel, this is "Microsoft Excel" in both cases.
But I couldn't find any kind of version information for HSSF.
Usecase: I get a lot of files from different sources and for support questions, it would be very helpful to know the Excel version a particular source uses. As you can also save a .xlsx as .xls, the BIFF version alone would not be of much help.

Related

FlexCel created corrupted xlsx file

I use the FlexCel library to create an Excel report in the .xlsx format.
When creating a file in .xls format - everything works fine.
When I try to create a file in the .xlsx format, the file is created, but when I open it by Excel, I get an error that the file is corrupt and can not be opened. And the file has the size in half from .xls.
If someone has encountered a similar problem or knows a solution, I will be very grateful for the answer.
Edit:
My code
var templateFilePath = "D:/template.xlsx";
var newReportPath = "D:/report.xlsx";
using (var fr = new FlexCelReport(true))
{
fr.AddTable("SOReport", dataTable);
fr.Run(
templateFilePath,
newReportPath
);
}
I had the same problem with export in xlsx format with old versions of FlexCel.
Currently I've tested it on FlexCel v5.5.1.0 and there is interesting behaviour:
If I use Excel 2016 or above to create xlsx templates - then I get "file is corrupted" error while trying to open exported xlsx file.
But if I use Excel 2013 or below to create xlsx templates - then I can open it perfectly without errors.
Also mention that if you open xlsx template created by Excel 2013 or below in Excel 2016 or above and save it - you can't restore it to working state in the future. Template will lost for you.
Too late but I hope this can help you.
P.S. Probably, FlexCel team (TMS Software) fixed it starting with v6.7.16.0 version of FlexCel. I think so because documentation said something similar: https://www.tmssoftware.com/site/flexcelnet.asp?s=history
Points like Improved : Improved compatibility with invalid xls and xlsx files
But I can't argue that.

Emending PDF files into OpenXML WordprocessingML

I am strugling with Open XML SDK and embedding pdf files into a docx file.
I do not want to use automation
I am able to create *.bin files from everything except from *.pdf (see this question)
Anyone has experience with this? From what I've gathered you must create a *.bin file in order to embedd any file into Word *.docx document (except images). Is that correct?
If you can't find a pure C# solution, you could consider the commercial product docx4j OLE Helper IKVM'd.
Disclosure: I wrote it.
The reason for pdf not working was in fact in acrobat reader.
When Ive installed older version (or did not have AR installed at all), it started to work.

compare openxml files

I'm developping a tool to manage some documents with versioncontrol. I have a windows client who is comparing 2 documents (previous version with current version) to see the differences between both documents. That is working fine (i'm using the interop dll's of microsoft).
I also have a web client where i want to do the same thing, but i don't want to install office on the server.
In my web client i only alow openxml files (docx, xlsx) because i can read and update versiondate in the document without having office installed.
Is there some tool where i can compare 2 openxml files with and show differences in a new document? (i already searched on it and there is some tool openxmldiff, but the results i get are some xml files and don't know how to combine them in a new document.
Any help?
You may want to take a look at OpenXml Powertools:
http://powertools.codeplex.com/
It has a DocumentComparer Class.
At least it is maybe a starting point.
The Open XML SDK 2.0 Productivity tool has a compare files option that will diff the two open xml files and show you the differences.

Is there any Open source Library to generate and edit .xls and .ppt file?

My task is to extract information from ppt file and compare with another ppt file. I have to use windows platform so i used excel and powerpoint's COM object.
After developing and testing the code in my computer when i exported the file into another computer it just failed. I started to debug in that file, and surprisingly debug was successful from first to last but as soon as click on the executable it fails.
I am totally *ucked up now cause inspite of updating excel dll files into those computers (which will serve the com support) it's not working. In every pc it gives different error message. I don't wanna work COM object anymore. It *ucks.
Can anyone suggest me any open source alternative in which i can read and extract information from Excel and Powerpoint files (both 2003 and 2007 format) ???
My preferred language is c# ........I got an paid solution (aspose) but i don't wanna go for that.
Any help will be appreciated. Just suggest me how can i deal with office files assuming ms office is not installed in my computer.
NPOI works well for Excel; I only know to use the built in, MS object library for PPT files.

Programmatically finding an Excel file's Excel version

I'm using an OleDbConnection to connect to a spreadsheet from a C# program. One of the parameters in the connection string is the Excel version.
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Book1.xls;Extended Properties="Excel 8.0;HDR=YES"
Given the path of an Excel file how can I find out which Excel format version it uses?
Thanks in advance,
T.
I addition to what was said and apart from using Excel automation to open the file you can try reading file version from your code:
xls files: those are saved as structured storage. you can use the technique from the article here: How To Determine Which Version of Excel Wrote a Workbook
xlsx files: you can open them as zip files. Version is in app.xml file AppVersion field.
Download OLE File Property Reader. Register dsofile.dll with regsvr32 and add it as a reference in your application. The following code will output the type of Excel file. It will not work on xlsx/docx since those are not OLE compunds object files, but should work on all older Office formats (2007/2003/XP).
var doc = new OleDocumentPropertiesClass();
doc.Open(#"c:\spreadhseet.xls", false, dsoFileOpenOptions.dsoOptionDefault);
Console.WriteLine(doc.OleDocumentType);

Categories