We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.Cells adds an extra row with borders if start cell (row) have borders defined in the template

If I set borders in the Excel template and then import data table. Data is added and borders are added as I’d like, but an extra empty row with borders is added to the merged spreadsheet.


How can we accomplish this without getting the extra empty row at the bottom?

code:

worksheet.Cells.ImportDataTable(_dataSource, False, “A4”)

Hi Travas,

Thanks for using Aspose.Cells.

Import data table inserts new rows and then inserts the data. That’s why your borders are added because it inserts the copies of first row. Could you please try the following overload and pass false to insertRows parameter and check your results.

Cells.ImportDataTable Method (DataTable, Boolean, Int32, Int32,
Int32, Int32, Boolean, String, Boolean)

Imports a DataTable into a worksheet.

public int ImportDataTable(
DataTable dataTable,
bool isFieldNameShown,
int firstRow,
int firstColumn,
int rowNumber,
int columnNumber,
bool insertRows,
string dateFormatString,
bool convertStringToNumber
);

Parameters

dataTable
The DataTable object to be imported.
isFieldNameShown
Indicates whether the field name of the datatable will be imported to the first row. Default is true.
firstRow
The row number of the first cell to import in.
firstColumn
The column number of the first cell to import in.
rowNumber
Number of rows to be imported.
columnNumber
Number of columns to be imported.
insertRows
Indicates whether extra rows are added to fit data.
dateFormatString
Date format string for cells.
convertStringToNumber
Indicates if this method will try to convert string to number.

Return Value

Total number of rows imported.

Remarks

This method automatically format date time values. However, if the DateTable is very huge, this method may slow down the program. In this case, you'd better format the cell manually.


This overload does not provide the desired results.


This overload leaves the row that has the bordering that I want on all of the rows that get imported and does not put bordering around the rows that were imported.

Hi Travas,

Thanks for your posting and using Aspose.Cells.

Kindly provide us your sample console application replicating this issue. If you will provide your actual and expected Excel file, it will also help us. You can provide expected output file by editing it manually using MS-Excel.

We will investigate your issue at our end. In case, you need a code change, we will suggest it. If it is a bug, we will log it in our database for investigation and a fix.

Besides, you can also apply style to your range of cells using Range.ApplyStyle() method. Also, you can delete your extra unwanted row using Cells.DeleteRow() method.