Spire.DataExport for .NET is a 100% pure data .NET library suit for exporting data into MS Word, Excel, RTF, Access, PDF, XPS, HTML, XML, Text, CSV, DBF, SYLK, SQL Script, DIF, Clipboard, etc.

Thu Oct 20, 2011 11:40 am

Hello,

When I export a datatable that has Null values in it, this is exported as values: NULL instead of an empty value.
Has can we fix this?

Thank you

calago
 
Posts: 8
Joined: Thu Oct 20, 2011 9:09 am

Mon Oct 24, 2011 7:07 am

Hello calago,

Sorry for any inconveniences caused by us and thank you for your patience with our reply.

I have used Spire.DataExport to export a null datatable to a CSV file. But the cells are empty without value and null. I attached a demo to you. You can have a try.
If you still have any other questions, please don't hesitate to contact us at any time for any things.

Have a nice day.
Attachments
ExportNullValue.zip
(22.8 KiB) Downloaded 725 times
Tina
Technical Support/Developer,
e-iceblue Support Team
User avatar

Tina.Lin
 
Posts: 152
Joined: Tue Sep 13, 2011 5:37 am

Tue Nov 15, 2011 10:56 am

Hello,

Sorry for the late reply.

The example you give is not what we mean. The problem is that if we export a DataTable which contains a NULL value, then in the CSV export it appears as "null" (with quotes). So if we do this:

Code: Select all
            DataTable table = new DataTable();
            table.Columns.Add("Column1");
            table.Columns.Add("Column2");
            table.Columns.Add("Column3");
            table.Rows.Add("Value row1 column1", "Value row1 column2", "Value row1 column3");
            table.Rows.Add("Value row2 column1", DBNull.Value, "Value row2 column3");

            TXTExport txtExport = new TXTExport();
            txtExport.ExportType = TextExportType.CSV;
            txtExport.DataTable = table;
            txtExport.DataSource = ExportSource.DataTable;
            txtExport.SaveToFile("TestWithNullValue.csv");


The resulting CSV file contains this:
Code: Select all
"Column1";"Column2";"Column3"
"Value row1 column1";"Value row1 column2";"Value row1 column3"
"Value row2 column1";"null";"Value row2 column3"

Please notice the "null" in the third line.

What we would expect (and what we need) is that it exports it like this:
Code: Select all
"Column1";"Column2";"Column3"
"Value row1 column1";"Value row1 column2";"Value row1 column3"
"Value row2 column1";;"Value row2 column3"

So the second value of the second row (third line) to just be empty.

I have included a sample project if it is still unclear to you.

Is there any way to accomplish this? Thanks in advance.

calago
 
Posts: 8
Joined: Thu Oct 20, 2011 9:09 am

Wed Nov 16, 2011 4:02 am

Hello,

Thank you for your inquiry.

When query results are viewed in SQL Server Management Studio Code editor(DataTable), null values are shown as NULL in the result set.
So, If you want to display the rusult as
Code: Select all
"Value row2 column1";;"Value row2 column3";

You only need to add row like this:
Code: Select all
table.Rows.Add("Value row2 column1", DBNull.Value.ToString(), "Value row2 column3");


If you still have any other question, please don't hesitate to contact us.
Have a nice day.
Tina
Technical Support/Developer,
e-iceblue Support Team
User avatar

Tina.Lin
 
Posts: 152
Joined: Tue Sep 13, 2011 5:37 am

Return to Spire.DataExport

cron