0

I have a CSV file, I am converting the CSV file into Excel using EpPlus, it is successfully converting to Excel but I have a problem, In the CSV file I have comma separated values in a column, so when EpPlus converts the CSV file into Excel these comma separated values are showing in individual columns in the generated Excel file.

Is there any way to resolve this issue?

This is the code which I am using to convert the CSV to Excel

using (ExcelPackage package = new ExcelPackage(new FileInfo(excelFilePath)))
{
    ExcelWorksheet worksheet = package.Workbook.Worksheets.Add(worksheetsName);

    worksheet = package.Workbook.Worksheets.Add(worksheetsName);
    worksheet.Cells["A1"].LoadFromText(new FileInfo(csvFilePath), format, OfficeOpenXml.Table.TableStyles.None, firstRowIsHeader);
    package.Save();
}

I am facing one more issue, I have time, date columns in the CSV file (both are individual columns) but in the generated excel file the format of time and date columns are not correct. For example if the time value in the CSV file is "12:00:00 AM" in the output Excel it is showing as 42639 and for the date 11/21/2016 it is showing as 42695. How can I correct the format issue?

One more question, Does EpPlus support XML to Excel spreadsheet conversion?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Hari
  • 11
  • 1
  • 4
  • I didn't understand, the comma separated values aren't getting separated? You should define the delimiter in your `format` variable (which you sould have posted in your question). Also, for date and time you have to change the `Format` of your cells, check this: http://stackoverflow.com/questions/22832423/excel-date-format-using-epplus – Magnetron Oct 20 '16 at 10:32
  • 1
    Do you have a sample of the CSV? The desired outout and the current output? – VDWWD Oct 22 '16 at 08:40

0 Answers0