i believe here are lot a discussion with this matter.
but i read all post and try but it never work with c#.
my goal is simple that i have existing csv file.
just want convert exel file and done.
many people said that using spire.xls something but i believe MS .office.interop.excel could handle it.
Converting Excel File From .csv To .xlsx
i read above issue and this is same as my problem.
but above code not work in my PC.. do i need to import other dll to use this.
i just copy code from that site. copy again below...
currently im using Lib as MS.office.interop.excel and MS.office.interop.core
Application app = new Application();
Workbook wb = app.Workbooks.Open(@"C:estcsv.csv", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
wb.SaveAs(@"C:estcsv.xlsx", XlFileFormat.xlOpenXMLWorkbook, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
wb.Close();
app.Quit();
here are lot a error. modify code is below and now im only using MS.office.interop.excel and MS.office.interop.core in my reference.
it looks like i need to use another dll file.
anyway i did follow that code and make new code.
it reduce error but i don't know this is correct approach.
below is what i tried now.
Excel.Application xlApp;
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;
object misValue = System.Reflection.Missing.Value;
System.Globalization.CultureInfo oldCI = System.Threading.Thread.CurrentThread.CurrentCulture;
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
xlApp = new Excel.ApplicationClass();
xlWorkBook = xlApp.Workbooks.Add(misValue);
xlWorkBook = xlApp.Workbooks.Open(@"C:estcsv.csv", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
xlWorkBook.SaveAs(@"C:estcsv.xlsx", XlFileFormat.xlOpenXMLWorkbook, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
xlWorkBook.Close();
and here are error message
Error 3 The name 'XlFileFormat' does not exist in the current
context C:UsersjochoiDesktopjoseph_BT_??_codeDC_Test -
ver01DC_TestDC.cs 528 54 DC_Test
Error 4 The name 'XlSaveAsAccessMode' does not exist in the current
context C:UsersjochoiDesktopjoseph_BT_??_codeDC_Test -
ver01DC_TestDC.cs 528 142 DC_Test
Error 4 No overload for method 'Close' takes '0'
arguments C:UsersjochoiDesktopjoseph_BT_??_codeDC_Test -
ver01DC_TestDC.cs 525 13 DC_Test
my goal is just grab exist csv file and just change to excel file.
does anyone has other solution because that answer is not work in my pc. (c#)
See Question&Answers more detail:
os