Cells.ImportDataTable() Not Working For Boolean DataType

Hello Lawrence,

I think I might have stumbled upon a bug in the Cells.ImportDataTable() method, and wanted to report it… Here the some C# code to reproduct it:

DataTable table = new DataTable();
table.Columns.Add(“BooleanColumn”, typeof(System.Boolean));
DataRow row = table.NewRow();
row[“BooleanColumn”] = true;
cells.ImportDataTable(table, false, 0, 0);

When I run that chunk of code, I get the following Exception:

System.Exception: Cell contains no data

The Cells.ImportDataTable() function seems to work for Strings, Ints, DateTimes, and Decimals, but not for Booleans…

Am I doing something wrong???



Hi Dana,

No one asked for Booleans before :). Now it’s available. Please download fix and have a try.

Thanks again for the prompt response… I’ll give it a try…:slight_smile:


We have introduced a new product Aspose.Cells which has replaced Aspose.Excel. This new product is far better than the discarded version Aspose.Excel in terms of performance and variety of features. All the latest features of MS Excel are incorporated into this new product and continuous up-gradation is done to meet the latest requirements. Aspose.Cells provides a variety of ways to import data into a worksheet. You may try the following sample code to achieve this functionality.

// Create directory if it is not already present.
bool IsExists = System.IO.Directory.Exists(dataDir);
if (!IsExists)

// Instantiating a Workbook object            
Workbook workbook = new Workbook();

// Obtaining the reference of the worksheet
Worksheet worksheet = workbook.Worksheets[0];

// Instantiating a "Products" DataTable object
DataTable dataTable = new DataTable("Products");

// Adding columns to the DataTable object
dataTable.Columns.Add("Product ID", typeof(Int32));
dataTable.Columns.Add("Product Name", typeof(string));
dataTable.Columns.Add("Units In Stock", typeof(Int32));

// Creating an empty row in the DataTable object
DataRow dr = dataTable.NewRow();

// Adding data to the row
dr[0] = 1;
dr[1] = "Aniseed Syrup";
dr[2] = 15;

// Adding filled row to the DataTable object

// Creating another empty row in the DataTable object
dr = dataTable.NewRow();

// Adding data to the row
dr[0] = 2;
dr[1] = "Boston Crab Meat";
dr[2] = 123;

// Adding filled row to the DataTable object

// Importing the contents of DataTable to the worksheet starting from "A1" cell,
// Where true specifies that the column names of the DataTable would be added to
// The worksheet as a header row
worksheet.Cells.ImportDataTable(dataTable, true, "A1");

// Saving the Excel file
workbook.Save(dataDir + "DataImport.out.xls");

You may review the following document which explains number of ways to import data into worksheet:
Import data into worksheet

You can download the latest version of this product here:
Aspose.Cells for .NET (Latest Version)

For a running solution containing hundreds of examples visit here.