6

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?

Saftpresse99
  • 849
  • 7
  • 16

2 Answers2

0

What you got is called the Flat OPC format. Here is an article about converting it to the regular Open XML format.

Marek Dzikiewicz
  • 2,844
  • 1
  • 22
  • 24
0

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)