c# - Microsoft.Office.Interop.Excel.Application SaveAs() method does not preserve encoding -
i'm having issue saving excel files csv's , preserving encoding in c#. specifically, following takes excel file , saves csv file same name, passed loadcsvdata function, job insert data database in organized fashion. issue excel file contains fractional symbols not recognized in csv format, unless manually open each .xml , save csv (for reason works while microsoft.office.interop.excel.application method saveas() not):
list<string[]> data = new list<string[]>(); string filename = (date.tostring("mm/dd/yyyy") + ".csv").replace("/",""); string excelfilename = (date.tostring("mm/dd/yyyy") + ".xml").replace("/",""); system.console.writeline("processing file: " + filename); system.console.readline(); // open excel , save csv. process data microsoft.office.interop.excel.application app = new microsoft.office.interop.excel.application(); microsoft.office.interop.excel.workbook workbook = app.workbooks.open(@"c:\users\tag\desktop\tip holdings\" + excelfilename); workbook.saveas(@"c:\users\tag\desktop\tip holdings\csv data\" + filename, microsoft.office.interop.excel.xlfileformat.xlcsv); workbook.close(false,"",true); data = loadcsvdata(filename); insertdata(data);
Comments
Post a Comment