Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
350
Exporting to .CSV
posted

Is there away to save data to csv file instead of excel. I am using a FileHelperEngine which is responsible for a comma delimited file. At the moment I am exporting to csv from the file dialog, but the filehelperengine does not recognized the file as csv until I resave to CSV from excel. i am currently doing this below

SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.InitialDirectory = @"C:\";
saveFileDialog1.Title = "Save EasyTimesheet CSV";
saveFileDialog1.DefaultExt = "csv";
saveFileDialog1.Filter = "CSV files (*.csv)|*.csv|All files (*.*)|*.*";
saveFileDialog1.FilterIndex = 2;
saveFileDialog1.FileName = filenameFormat;

saveFileDialog1.RestoreDirectory = true;

if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
return saveFileDialog1.FileName;
}
else
return filename;
}

--------------------

this.dgTimeSheets.DataSource = _DataViewCSVImport;

FileInfo fileInfo = new FileInfo(filename);

Workbook workbook = new Workbook(WorkbookFormat.Excel2007);
Worksheet ws1 = workbook.Worksheets.Add(fileInfo.Name);

DataPresenterExcelExporter exporter = new DataPresenterExcelExporter();

exporter.Export(this.dgTimeSheets, workbook);
workbook.Save(filename);