@Adhirath
Thank you for your feedback. You are welcome. These modifications will be reflected in the next version v25.6 which will be released in the first half of June 2025. We will notify you promptly once version v25.6 is released.
The issues you have found earlier (filed as CELLSNET-58430) have been fixed in this update. This message was posted using Bugs notification tool by leoluo
Great! I had a small doubt guys is there a method to get the address of a table?
@Adhirath
Please refer to the following example code to get the table address.
ListObject listObject = "your table object";
Console.WriteLine(listObject.DataRange.Address);
Hope helps a bit.
will this include the headers or just the data, is there a way to get the range for the entire table. So if there is a range CN156:CR174 and it has a table with range CN160:CR167, i want the range for the table
@Adhirath
Please refer to the following code to get the table range and table data range.
ListObject listObject = workbook.Worksheets[0].ListObjects["your table object"];
//table range
string startCell = CellsHelper.CellIndexToName(listObject.StartRow, listObject.StartColumn);
string endCell = CellsHelper.CellIndexToName(listObject.EndRow, listObject.EndColumn);
Range range = sheet.Cells.CreateRange(startCell, endCell);
Console.WriteLine(range.Address);
//table data range
Console.WriteLine(listObject.DataRange.Address);
Hope helps a bit.
Thanks for the replay. I am facing another issue. The table created is wider when compared to a table which is pasted directly from excel. below is a word document containing 2 tables, 1 created using aspose by converting xlsx to docx and the other copy pasted from excel.
Code-
PageSetup-
worksheet.AutoFitRows();
worksheet.PageSetup.PrintArea = printArea;
worksheet.PageSetup.LeftMargin = 0;
worksheet.PageSetup.RightMargin = 0;
worksheet.PageSetup.TopMargin = 0;
worksheet.PageSetup.BottomMargin = 0;
ImgOrPrintOptions-
ImageOrPrintOptions originalImgOptions = new ImageOrPrintOptions
{
OnePagePerSheet = true,
OnlyArea = true,
ImageType = ImageType.OfficeCompatibleEmf,
};
is there a way to fix the issue?
word doc-
Document_1750066092.zip (31.3 KB)
Thank you for sharing the Word document.
Could you please also provide the source XLSX file? This will help us evaluate your issue more effectively using Aspose.Cells APIs on our end.
I tested your scenario/case using your template Excel file and following sample code. I found both Aspose.Cells and copy/paste table from Excel work the same way. I got approximately same results.
e.g.,
Sample code:
Workbook workbook = new Workbook("e:\\test2\\ExcelFormats.xlsx");
foreach (Worksheet worksheet in workbook.Worksheets)
{
if (worksheet.Index > 0)
{
ListObject listObject = worksheet.ListObjects[0];
//table range
string startCell = CellsHelper.CellIndexToName(listObject.StartRow, listObject.StartColumn);
string endCell = CellsHelper.CellIndexToName(listObject.EndRow, listObject.EndColumn);
Aspose.Cells.Range range = worksheet.Cells.CreateRange(startCell, endCell);
worksheet.AutoFitRows();
worksheet.PageSetup.PrintArea = range.Address;
worksheet.PageSetup.LeftMargin = 0;
worksheet.PageSetup.RightMargin = 0;
worksheet.PageSetup.TopMargin = 0;
worksheet.PageSetup.BottomMargin = 0;
//table data range
//Console.WriteLine(listObject.DataRange.Address)
}
}
DocxSaveOptions docxSaveOptions = new DocxSaveOptions();
workbook.Save("e:\\test2\\outdocument1_Aspose.Cells.docx", docxSaveOptions);
outdocument1_Aspose.Cells.docx (14.1 KB)
Please also find attached MS Word file when copying/pasting from Excel for the table in the second worksheet.
outdocument1table1_excel.zip (14.3 KB)
In case you still find the issue, kindly share your exact (runnable) sample code (same as above), sample files and provide some screenshots to highlight with problematic areas, we will check it soon.
I use the same logic, below is the code. I convert it to flatopc as I need the ooxml content. Could that be causing the issue?
code-
docx conversion code.zip (1.3 KB)
Please provide the changes in the same shared text file in order to maintain privacy in case there are any.
@Adhirath
We export Excel file to docx as printing. When printing the sheet in Excel, the width of the columns will be scaled up. So result of aspose.cells is larger than copied from Excel.
If we export as the view of MS Excel, sometimes the paging will be totally different .
We will check how to work as copying.
sure, let me know if there is anything I can tweak to make it more in line with excel paste.
@Adhirath
Thank you for your feedback. We will notify you promptly once there are any updates.
@Adhirath
We have opened the following new ticket(s) in our internal issue tracking system for width of columns and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s):CELLSNET-58602
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
@Adhirath
Please check
dest.docx (14.1 KB)
which is generated by inner hot fix 25.6.1 with docxSaveOptions.AsNormalView = true .
We have added AsNormalView Boolean attribute under DocxSaveOptions class now allowing you to replicate the functionality of copying and pasting from Excel. After your confirmation, the fix will be included in the upcoming release (Aspose.Cells v25.7) that we plan to release in the first half of July 2025. You will be notified when the next version is published.
Looks great guys! thanks a lot!!!
Thanks for the confirmation. You may expect the new release: Aspose.Cells v25.7 (which will include this enhancement/fix) in the second week of July 2025.
The issues you have found earlier (filed as CELLSNET-58602) have been fixed in this update. This message was posted using Bugs notification tool by leoluo