Reading merged Cell value while Exporting Data from Excel to a Datatable

Hi,

I have an excel sheet which has both merged and unmerged cells like shown below

Mgr1 abc 10% 20%
dfg 20% 35

when i try to export to a datatable using ExportToDatatable option, i am geeting the out put as shown below

Mgr1 abc 10% 20%
dfg 20% 35

How to get the Mgr1 in the 2nd Row aslo(which colored in orange).

I have another excel sheet,which has data as shown below

Country Category
abc xyz
zzzz 120 130

Expected result is

Country Category
zzzz abc 120
zzzz xyz 130

how to get the result

please provide the possible solution asap

Thanks & Regards,

Babu Benny

Hi Babu Benny,


Well, ExportDataTable exports the data based on the displayed cells, so, if a cell is merged (A1:A2 – > A1), its value in the main cell would be considered. ExportDataTable works in the same way as Copy/Paste feature of MS Excel. For confirmation, you may try to copy the range i.e. A1:D2 to paste it into other location in MS Excel or even into other packages like notepad, you will see that it provides the same output as Aspose.Cells does for ExportDataTable method.

For your requirements, you have to do it by yourself, you need to first unmerge the merged cells and then manually copy/input the values (your desired values) into those cells, then, finally export the data to DataTable for your requirements.

Thank you.

Hi,

Please refer to this document for your help. This document explains how you can programmatically merge/unmerge cells.

Merging / UnMerging Cells in the Worksheet

Please also download and use the latest version:
Aspose.Cells
for .NET v7.1.1.6