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

Free Support Forum - aspose.com

Copied rows does not have the same row height as source

Hi there Aspose,


I would like to ask for help on row height after copying some rows.
where Aspose does not behave like Excel.

ENVIRONMENT:
Aspose 8.9.0.5
Excel 2013

PROBLEM:
When I am copying rows using ws.Cells.CopyRows(),
I have found out that some rows do not have their final* row height copied correctly.
*Using GetRowHeight() before saving gives me the correct value (11.25)!

RESULT:
- Aspose
The result is correct for rows with height == 19.5 and 15.75
where as copying rows with row height 11.25 gives me 12.75 when opened in excel
- Excel
2/3 of my testing machines gives the exact same row height (11.25 == 11.25)
the last machine gives me behaviour similar to Aspose.


POSSIBLE REASON:
*I have attached the excel :slight_smile: *
The rows to be copied sized from 11.25 to 19.5
This problem started to appear when my colleague tested on my program,
where he has checked some options in the cell format,
something to do with “fit text to column width” etc. ( I guess? )

Steps: I did with aspose copyRows()
“Invoice” is the source worksheet
"Result" is the destination worksheet
1. Result.Cells.CopyRows(Invoice.Cells, 0, 0, 20)
2. Result.Cells[“O1”].value = getRowHeight()…etc.
3. wb.Save(“MID.xlsx”)
4. Check row height on Excel 2013

Tests: on Excel copying for all 3 machines
Test 1. Mouse highlighting “Invoice!A1:L20”; ctrl + c; ctrl + v on "Result!"
Test 2. Mouse highlighting “Invoice!$A:$L”…
Test 3. Mouse highlighting “Invoice!” row 1 to 20…

Sorry for the long post :slight_smile:
and no potatoes

Regards,
Jonathan Lau

Hi Jonathan,


Thank you for sharing the sample.

We have evaluated the presented scenario while using the Aspose.Cells for .NE 8.9.0.7 & we are able to notice that said problem, that is; row heights are not being copied correctly with Cells.CopyRows operation. We have logged this incident as CELLSNET-44651 for further investigation. Please spare us little time to properly analyze the case and revert back with updates in this regard.

C#

// Instantiating a Workbook object
Workbook workbook = new Workbook(dir + “MID.xlsx”);
// Accessing the Invoice worksheet from the Excel file
Worksheet invoice = workbook.Worksheets[“Invoice”];
// Adding another worksheet as Result
Worksheet result = workbook.Worksheets[workbook.Worksheets.Add()];
// Copying first 20 rows to Result
result.Cells.CopyRows(invoice.Cells, 0, 0, 20);
for(int i=0; i<20;i++)
{
Console.WriteLine(result.Cells.GetRowHeight(i) + " " + invoice.Cells.GetRowHeight(i));
}
// Saving the modified Excel file
workbook.Save(dir + “output.xlsx”);

Hi again,


This is to update you that we have looked further into the details of the mentioned issue, and we regret to inform you that we will not be able to resolve the problem in short time. Reason being, the rows 3, 4 and so on do not have any style therefore the empty cells’ styles are being applied by the columns. Please note, when we copy rows, the Aspose.Cells APIs only copy cells and row’s setting, Aspose.Cells APIs do not copy the empty cells otherwise the file’s size will be huge. Moreover, in the resultant sheet, the empty cells’ style is default (Arial 10) and the row height’s are matched to the font’s height.

That said, we suggest you to try the following workaround for the time being, that is; copy the row heights to the destination rows.

C#

// Instantiating a Workbook object
Workbook workbook = new Workbook(dir + “MID.xlsx”);
// Accessing the Invoice worksheet from the Excel file
Worksheet invoice = workbook.Worksheets[“Invoice”];
// Adding another worksheet as Result
Worksheet result = workbook.Worksheets[workbook.Worksheets.Add()];
int numberOfRows = 20;
// Copying first 20 rows to Result
result.Cells.CopyRows(invoice.Cells, 0, 0, numberOfRows);
// Copying row heights
for(int i=0; i< numberOfRows; i++)
{
result.Cells.SetRowHeight(i, invoice.Cells.GetRowHeight(i));
}
// Saving the modified Excel file
workbook.Save(dir + “output.xlsx”);

Dear BaBar,


I will follow the workaround for now.
Thank you very much for the quick reply,

regards,
Jonathan

Hi Jonathan,


Thank you for your understanding. As soon as we have made significant progress towards fixing the said problem, we will share the estimated release schedule here for you reference. In the meanwhile, please feel free to get in touch if you have any other concerns or questions.

Hi,

Thanks for using Aspose.Cells.

We have closed this ticket CELLSNET-44651 as Won’t Fix. Let us know if you are still having any issue, we will look into it and re-open it if necessary.