Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

New Post: Whats different to a file saved in excel?

$
0
0
Just to explain..I add the following code to work around this issue (shouldn't have to in my opinion)
It effectively opens the file and saves it again
            Dim excelApp = New Microsoft.Office.Interop.Excel.Application()
            Dim excelWb = excelApp.Workbooks.Open(exportToFilePath)
            excelWb.Application.DisplayAlerts = False
            excelWb.SaveAs(Filename:=exportToFilePath, FileFormat:=Microsoft.Office.Interop.Excel.XlFileFormat.xlOpenXMLWorkbook)
            excelWb.Close()
            excelApp.Quit()
If someone could point out what I'm doing wrong in the first place, I'd appreciate it greatly as adding Excel interops makes me feel queasy

For the record..my code to create the original doc is as simple as
            Dim wb As New XLWorkbook()
            Dim ws = wb.Worksheets.Add("Changed Products")

            ws.Cell(1, 1).InsertTable(changedProducts)
            ws.Cell(1, 1).Value = "Product ID"
            ws.Cell(1, 2).Value = "SKU"
            ws.Cell(1, 3).Value = "EAN"
            ws.Cell(1, 4).Value = "MPN"
            ws.Cell(1, 5).Value = "Name"
            ws.Cell(1, 6).Value = "UPC"

            ws.Columns.AdjustToContents() 'Adjust the column widths

            wb.Properties.Title = "Changed Data Export"
            wb.Properties.Company = "My company"

            wb.SaveAs(exportToFilePath) 'Save the file

Viewing all articles
Browse latest Browse all 1877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>