i have got a XML-Excel file (SpreadsheetML format):
<?xml version="1.0" encoding="utf-8"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas- microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Company>My Company</Company>
</DocumentProperties>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="stTxt">
<Font ss:FontName="Arial" ss:Size="8"/>
<Alignment ss:Horizontal="Left"/>
<NumberFormat ss:Format="@"/>
</Style>
<Style ss:ID="stTopHeadline">
<Font ss:FontName="Arial" ss:Size="8" />
<Alignment ss:Horizontal="Left"/>
<NumberFormat ss:Format="@"/>
</Style>
...
Now i need to convert those files into XLSX-Files with C#. Is there a way with Open Xml or other libraries to convert it into Excel 2010 XLSX format?
What you got is called the Flat OPC format. Here is an article about converting it to the regular Open XML format.
Here is an easy example how to convert it with Python and an installed Excel. Prerequisite: Microsoft Excel must be installed on the computer!
import os
from win32com.client import Dispatch
def convert_xls_to_xlsx(oldName:str, newName:str):
oldName = os.path.abspath(oldName)
newName = os.path.abspath(newName)
xlApp = Dispatch("Excel.Application")
wb = xlApp.Workbooks.Open(oldName)
wb.SaveAs(newName,51)
wb.Close(True)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With