brechtsanders / xlsxio

XLSX I/O - C library for reading and writing .xlsx files
MIT License
397 stars 113 forks source link

Impossible to open xlsx files by Microsoft Excel Viewer on Windows systems #91

Closed vmendl closed 3 years ago

vmendl commented 3 years ago

It is not possible to open xlsx files by Microsoft Excel Viewer or Office professional plus 2016. Solution is to remove tag <AppVersion>xxxx</AppVersion> from app.xml. Tag <AppVersion> must be valid Microsoft Excel version. Tag <Application> is not checked by Microsoft Excel. Include version in tag <Application> as in Libre office and remove tag <AppVersion>. Best regards Vladimir

haephrati commented 3 years ago

I have the same problem. Even when xlsxio is used to open a file and save it with no changes, its then impossible to open it from Office, as it is shown "corrupted". image

brechtsanders commented 3 years ago

Which version of XLSX I/O did you use? Can you send the log file listing repairs?

haephrati commented 3 years ago

I integrated the latest version to a Visual Studio 2017 project as a static lib. Where should I find such log file?

On Thu, Mar 11, 2021 at 11:59 AM Brecht Sanders @.***> wrote:

Which version of XLSX I/O did you use? Can you send the log file listing repairs?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/brechtsanders/xlsxio/issues/91#issuecomment-796652311, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYGDPKLNISZLNC7CP7MVEDTDCPCDANCNFSM4U32OXSA .

brechtsanders commented 3 years ago

By clicking on the link below the error (see your own screenshot, just above the Close button)

haephrati commented 3 years ago
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><logFileName>error107920_01.xml</logFileName><summary>Errors were detected in file 'https://d.docs.live.net/ea373ad9f9c16144/Documents/Billboards Project/test.xlsx'</summary><additionalInfo><info>Excel completed file level validation and repair. Some parts of this workbook may have been repaired or discarded.</info></additionalInfo></recoveryLog>
vmendl commented 3 years ago

Solution is - delete line 156 from master/lib/xlsxio_write.c and xlsx file is readable from Office const char* docprops_app_xml =

156 "\<AppVersion>" XLSXIO_VERSION_STRING "\</AppVersion>" OPTIONAL_LINE_BREAK

haephrati commented 3 years ago

I deleted the line and tried again. The code now is:

const char* docprops_app_xml =
  XML_HEADER
  "<Properties xmlns=\"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties\" xmlns:vt=\"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes\">" OPTIONAL_LINE_BREAK
  "<Application>" XLSXIOWRITE_NAME "</Application>" OPTIONAL_LINE_BREAK
  "</Properties>" OPTIONAL_LINE_BREAK;

Got the following log:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><logFileName>error141080_01.xml</logFileName><summary>Errors were detected in file 'https://d.docs.live.net/ea373ad9f9c16144/Documents/Billboards Project/newtest.xlsx'</summary><additionalInfo><info>Excel completed file level validation and repair. Some parts of this workbook may have been repaired or discarded.</info></additionalInfo></recoveryLog>
haephrati commented 3 years ago

I will also upload a sample file that was saved with xlsxio_write.c. newtest.xlsx

brechtsanders commented 3 years ago

Fixed in xlsxio_write.c

haephrati commented 3 years ago

Checked the updated version but still get:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><logFileName>error123880_01.xml</logFileName><summary>Errors were detected in file 'https://d.docs.live.net/ea373ad9f9c16144/Documents/Billboards Project/test.xlsx'</summary><additionalInfo><info>Excel completed file level validation and repair. Some parts of this workbook may have been repaired or discarded.</info></additionalInfo></recoveryLog>

Test file attached. test2.xlsx