Open WorkBook / CSV Cells Containing Delimiter

Is there a way to open a workbook / csv file that contains column data (text) containing the delimiter?

I have come across a problem that when i open a file that contains a cell with text including the delimiter, when i save the worksheet it screws up the column data positioning.

The code I am using is as follows:

    // Step 1 : Instantiate the spreadsheet creation engine.
    ExcelEngine  excelEngine = new ExcelEngine();

    // Step 2 : Instantiate the excel application object.
   IApplication  application = excelEngine.Excel;
                       
   // Open the file
   IWorkbook   workbook = application.Workbooks.OpenReadOnly(<FileName>);

   // Set Worksheet
   IWorkSheet worksheet = workbook.Worksheets[0];

   ***************************************************************************
   The worksheet contains mismatched data from file containing columns with delimiter in text
   ****************************************************************************
  
   // Save File
    workbook.SaveAs(fileName, ExcelSaveType.SaveAsXLS);

Cheers

Simon


Note File_6d187645.zip

1 Reply

MK Manoj Kumar G M Syncfusion Team June 13, 2013 03:59 AM UTC

Hi Simon Finch,

Thank you for choosing Syncfusion products.

XlsIO provides support for reading and writing CSV files. The following code example illustrates how to open a .csv file with “,” as a delimiter.

// Opening a CSV File.
IWorkbook workbook = application.Workbooks.Open("CSVfile.csv", ",");


Please refer the below online documentation link for more information


Please let us know if you require any further clarifications.

Regards,
Manojkumar.

Loader.
Up arrow icon