How to get HTML of selected range in excel

Is there way to get HTML of selected range Excel.
I am giving namedRange in excel I want Html for that named range. In there If there is Merege row,coloumn and cells are there than i want that information in HTML(Colspan,rowspan).

@Jayshiv,

When you render to HTML, whole worksheet contents/data and other objects are considered or included (this is same with MS Excel’s HTML rendering). I think you may copy the range to other worksheet (you may add a new worksheet to the workbook) and then render to HTML via Aspose.Cells APIs for your needs.

1 Like

@Jayshiv
Hi, if you want to print a specific area, you can use the ExportArea method. Here is an example, I hope it can help you.

            HtmlSaveOptions options = new HtmlSaveOptions();
            options.ExportPrintAreaOnly = true;
            options.ExportArea = CellArea.CreateCellArea("B5", "E7");
            Workbook wb = new Workbook("yourFile.xlsx");
            wb.Save("out.html", options);
1 Like

@Jayshiv
You can convert a named range into a CellArea object using the following sample code.

// Getting the specified named range
Range namedRange = workbook.Worksheets.GetRangeByName("MyRange");

// Get CellArea object via named range
CellArea area =  CellArea.CreateCellArea(namedRange.FirstRow, namedRange.FirstColumn, namedRange.RowCount, namedRange.ColumnCount);

Hope helps a bit.

1 Like

Thanks @John.He,@xinya.zhu & @amjad.sahi For your Quick response it’s help me a lot.

@Jayshiv
Thank you for your feedback. You are welcome. If you have any questions, please feel free to contact us.

1 Like

Hi team In Excel I give NameRange to range After that I add/delete/merge Row/Coloumn.
Is there way I can find position where it’s add/delete/merge.
(I have also a old version of that excel file so using that I can find Postion for that.)

@Jayshiv,

You need to track it by yourselves in code via named ranges and its relevant APIs as there is no single option/command to evaluate it. If you know any such command/option available in MS Excel, kindly give details with sample Excel file(s) (please zip the files prior attaching). We will check on how to do it via Aspose.Cells APIs.

@Jayshiv
Do you mean that you want to get changed range after add/delete/merge?

1, Get the range from the defined name with WorksheetCollection.GetRangeByName(“MyRange”) again.
2, Add the Range to Cells.Ranges list(Cells.Range.Add(range)), we will update the ranges in Cells.Ranges when add/delete/merge.