C# Export CSV file with semicolon -
i want convert excel file csv , wrote c# code:
excel.application excelapp = new excel.applicationclass(); excel.workbooks workbooks = excelapp.workbooks; excelapp.displayalerts = false; excel.workbook workbook = workbooks.open(sourcefile, 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); workbook.saveas(csvfilepath, excel.xlfileformat.xlcsv, type.missing, type.missing, type.missing, type.missing, excel.xlsaveasaccessmode.xlnochange, type.missing, type.missing, type.missing, type.missing, type.missing); workbook.close(false, sourcefile, null); excelapp.displayalerts = true; excel.application app = excelapp.application; app.quit(); marshal.releasecomobject(workbooks); marshal.releasecomobject(workbook); marshal.releasecomobject(excelapp); marshal.releasecomobject(app); sourcefile = csvfilepath; but csv file seperated commas. have searched on internet. tried region setting , other things, none of them solved problem.
example output: hesap,391,tl,,,
i want output: hesap;391;tl;;;
i had same problem, - had migrate 1 project windows server 2003 windows server 2012, , one
workbook.saveas(csvfilepath, excel.xlfileformat.xlcsv, type.missing, type.missing, type.missing, type.missing, excel.xlsaveasaccessmode.xlnochange, type.missing, type.missing, type.missing, type.missing, type.missing);
and csv file separated commas instead of semicolons. found 1 solution helped me avoid problem
formatting:
obook.saveas(newfilename, xlfileformat.xlunicodetext, missing, missing, false, false, xlsaveasaccessmode.xlnochange, missing, missing, missing, missing, missing); and after rewrite file way:
string text = file.readalltext(newfilename); text = text.replace("\t", ";").replace("{tab}", "\t"); file.writealltext(newfilename, text, encoding.utf8); so have csv file separated semicolons. problem left - fileds date , float values have format, - date 10/5/2015 18:54 instead of 5.10.2015 18:54 , float values 5.55 instead of 5,55.
i think last 2 problems decide converting vaules in oracle procedures, main problem passed - have same csv file need.
some of developers may suppose comma right , semicolon not or not difference between these delemiters, if have big project there procedures on server side work in 1 way difficult set , correct of them.
and don't understand 1 thing - if have comma in field in excel file , use method workbook.saveas, how take correct value of field further? - there 2 values instead of one! semicolon situation same, never use semicolons in our excel files.
Comments
Post a Comment