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);

Parents
  • 3520
    Offline posted

    Hello Darnell,

     

    Currently, the Workbook class does not support saving and loading to and from CSV files. It only supports the formats found in the WorkbookFormat Enumeration described in the following topic:

    http://help.infragistics.com/doc/WPF/2015.2/CLR4.0/?page=InfragisticsWPF4.Documents.Excel.v15.2~Infragistics.Documents.Excel.WorkbookFormat.html

    The following table illustrates how these formats map to MS Excel formats:


    Member

    Description

    Excel Save As Dialog Format

    Excel2007

    The Excel 2007 XML file format.

    Excel Workbook (*.xlsx)

    Excel2007MacroEnabled

    The Excel 2007 Macro-Enabled XML file format.

    Excel Macro-Enabled Workbook (*.xlsm)

    Excel2007MacroEnabledTemplate

    The Excel 2007 Macro-Enabled Template XML file format.

    Excel Macro-Enabled Template (*.xlst)

    Excel2007Template

    The Excel 2007 Template XML file format.

    Excel Template (*.xltx)

    Excel97To2003

    The Excel 97-2003 BIFF8 file format.

    Excel 97-2003 Workbook (*.xls)

    Excel97To2003Template

    The Excel 97-2003 Template BIFF8 file format.

    Excel 97-2003 Template (*.xlt)

    StrictOpenXml

    The Strict Open XML file format (ISO/IEC 29500 Strict).

    Strict Open XML Spreadsheet (*.xlsx)


    If you have any further questions on the matter do not hesitate to contact us.



Reply Children
No Data