We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Empty Dataset when Exporting to CSV or XLSX

Hi,

I have a grid with two columns and a header row.
The grid contains 49 rows.
If I export it to excel (csv or xlsx) the file contains
51 rows.
The first row is the header with column names, then I have 49 rows with data.
And at the end I have one empty row.
In xlsx it is not visible, but when I export it to csv then row 51 only contains a separator ";".

My grid has the following implementation:

dataGrid = new SfDataGrid();

dataGrid.HeightRequest = 200;

dataGrid.ColumnSizer = ColumnSizer.Star;

dataGrid.AutoGenerateColumns = false;

dataGrid.ItemsSource = sensor.RecordingData.Data;

dataGrid.SetBinding(SfDataGrid.IsBusyProperty, "sensor.RecordingData.IsLoading");

GridTextColumn col = new GridTextColumn() {

HeaderText = "Time",

MappingName = "DateTimeString",

TextWrapping = LineBreakMode.CharacterWrap

};

col.LoadUIView = true;

dataGrid.Columns.Add(col);

col = new GridTextColumn() {

HeaderText = "Pressure",

MappingName = "Pressure"

};

col.LoadUIView = true;

dataGrid.Columns.Add(col);


To export I use the following method:


private void ExportToExcel() {

DataGridExcelExportingController excelExport = new DataGridExcelExportingController();

if (dataGrid.View.Records.Count > 0) {

var excelEngine = excelExport.ExportToExcel(this.dataGrid);

var workbook = excelEngine.Excel.Workbooks[0];

MemoryStream stream = new MemoryStream();


//workbook.SaveAs(stream, ";");

//workbook.Close();

//excelEngine.Dispose();

//DependencyService.Get<ISave>().Save(String.Format("Recording-{0:yyyy-MM-dd-hh-mm-ss}.csv", DateTime.Now), "text/csv", stream);

workbook.SaveAs(stream);

workbook.Close();

excelEngine.Dispose();

DependencyService.Get<ISave>().Save(String.Format("Recording-{0:yyyy-MM-dd-hh-mm-ss}.xlsx", DateTime.Now), "application/msexcel", stream);

}


}

In my example the debugger tells me that dataGrid.View.Records.Count has a value of 49.

But workbook.ActiveSheet.Rows has 51 elements and that is also what I see in my exported file.

The csv contains the following data:

Time;Pressure
11.05.2016 14:33:50.548;54,38
11.05.2016 14:33:50.748;55,38
11.05.2016 14:33:50.948;56,38
11.05.2016 14:33:51.148;57,38
11.05.2016 14:33:51.348;58,38
11.05.2016 14:33:51.548;59,38
11.05.2016 14:33:51.748;60,4
11.05.2016 14:33:51.948;61,38
11.05.2016 14:33:52.148;62,38
11.05.2016 14:33:52.348;63,38
11.05.2016 14:33:52.548;64,38
11.05.2016 14:33:52.748;65,4
11.05.2016 14:33:52.948;66,38
11.05.2016 14:33:53.148;67,38
11.05.2016 14:33:53.348;68,38
11.05.2016 14:33:53.548;69,38
11.05.2016 14:33:53.748;70,4
11.05.2016 14:33:53.948;71,38
11.05.2016 14:33:54.148;72,38
11.05.2016 14:33:54.348;73,38
11.05.2016 14:33:54.548;74,38
11.05.2016 14:33:54.748;75,4
11.05.2016 14:33:54.948;76,38
11.05.2016 14:33:55.148;77,38
11.05.2016 14:33:55.348;78,38
11.05.2016 14:33:55.548;79,38
11.05.2016 14:33:55.748;80,4
11.05.2016 14:33:55.948;81,38
11.05.2016 14:33:56.148;82,38
11.05.2016 14:33:56.348;83,38
11.05.2016 14:33:56.548;84,38
11.05.2016 14:33:56.748;85,38
11.05.2016 14:33:56.948;86,38
11.05.2016 14:33:57.148;87,38
11.05.2016 14:33:57.348;88,38
11.05.2016 14:33:57.548;89,38
11.05.2016 14:33:57.748;90,38
11.05.2016 14:33:57.948;91,38
11.05.2016 14:33:58.148;92,38
11.05.2016 14:33:58.348;93,38
11.05.2016 14:33:58.548;94,38
11.05.2016 14:33:58.748;95,38
11.05.2016 14:33:58.948;96,38
11.05.2016 14:33:59.148;97,38
11.05.2016 14:33:59.348;98,38
11.05.2016 14:33:59.548;99,38
11.05.2016 14:33:59.748;100,38
11.05.2016 14:33:59.948;1,38
11.05.2016 14:34:00.148;2,38
;

If I save the data as xslx and the convert it in excel to a csv file the file looks

the same.

What am I doing wrong?





1 Reply

HN Harikrishnan N Syncfusion Team June 3, 2016 04:15 AM UTC

Hi MNHUSSAIN,

Thank you for using Syncfusion Products.

We were able to reproduce the issue “Exporting the grid contains a separator ‘;’ in the end” from our side. We confirm it as a defect and have logged a defect report on it. We will fix this issue internally and it will be available in our upcoming VOL 2 main release which is scheduled by the mid of June. We appreciate your patience until then.

Regards,
Harikrishnan 


Loader.
Live Chat Icon For mobile
Up arrow icon