Я создал файл Excel, используя OpenXML. Но когда я пытаюсь открыть созданный xlsx, это сообщение об ошибке отображалось.
«Конвертеру не удалось сохранить файл»
Я уже установил этот «FileFormatConverters.exe»
Вот мой код:
Использование sp As SpreadsheetDocument = SpreadsheetDocument.Create ("C: \ OpenXML.xlsx", SpreadsheetDocumentType.Workbook)
Dim wBookPart As WorkbookPart = sp.AddWorkbookPart
Dim wBook As Workbook = New Workbook
Dim sheet As Sheet = New Sheet
Dim sheets As Sheets = New Sheets
sheet.Name = "TestSheet"
sheet.Id = "r1d1"
sheets.Append(sheet)
wBook.Append(sheets)
wBookPart.Workbook = wBook
Dim wSheetPart As WorksheetPart
wSheetPart = wBookPart.AddNewPart(Of WorksheetPart)("r1d1")
Dim wSheet As Worksheet = New Worksheet
Dim sData As SheetData = New SheetData
Dim row1 As Row = New Row
Dim cell1 As Cell = New Cell
cell1.DataType = CellValues.InlineString
cell1.CellReference = "A1"
Dim iString As InlineString = New InlineString
Dim txt As Text = New Text
txt.Text = "hello test"
iString.Append(txt)
cell1.Append(iString)
row1.Append(cell1)
sData.Append(row1)
wSheet.Append(sData)
wSheetPart.Worksheet = wSheet
sp.WorkbookPart.Workbook.Save()
End Using