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

Free Support Forum - aspose.com

Two Dimensional Cell array of column without creating a named range

Hi,

I have one requirement where I want to access two dimensional cell array for the given startcolumn, endcolumn, startrow and endrow without creating a named range.

Please suggest me the APIs that I should use.

The piece of code for the same will be more helpful.

Thank You.
Kailas Kore

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

Well, I am not very sure whether you want to import the data from 2-Dimensinal array to worksheet or you want to export the data from worksheet to 2-Dimensional array. Please see the sample code for both importing and exporting the data to and from the worksheet.

Sample Code Importing from 2-D Array to Worksheet :-

Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
sheet.Cells["A1"].PutValue("Import an Array");
sheet.Cells["A1"].Style.Font.IsBold = true;
string[,] arr = new string[2, 2];

arr[0, 0] = "Aspose";
arr[0, 1] = "Cells";
arr[1, 0] = "For";
arr[1, 1] = "NET";
sheet.Cells.ImportArray(arr, 1, 0);
workbook.Save("ImportingData.xls", FileFormatType.Default, SaveType.OpenInExcel, this.Response);

Sample Code Exporting from Worksheet to 2-D Array:-

Workbook workbook = new Workbook();
workbook.Open(@"C:\ImportingData.xls");
Worksheet sheet = workbook.Worksheets[0];
object[,] arr = sheet.Cells.ExportArray(1, 0, 2, 2);

Thank You & Best Regards,

Thanks for you quick reply.

I would like to get the array of cells and not values.

Thank You.

The namedRange.getCells() gives me two dimensional array of all the cells (cell objects) from the named range.

I want two dimensional array of all the cells (cell objects) from the range without creating any named range, simply I will provide startrow, startcolumn, endrow and endcolumn.

Thank You.


Hi,

Any updates on this part?

Thank You.
Kailas

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

Please try the attached latest fix. We have provided a new API for Cells object: Cells.getCells(int startRow, int startColumn, int endRow, int endColumn) which will return a two-dimensional array of Cell object. Hopefully, it will meet your requirements.

Thank You & Best Regards,

Hi,

We are facing some issues in the version of Aspose.Cells that you have provided.

Our first phase is in production on the Aspose.Cells V1.9.5.1 for Java.

Please provide the API for Cells object:
Cells.getCells(int startRow, int startColumn, int endRow, int
endColumn) which will return a two-dimensional array of Cell object in version V1.9.5.1.

I am not able to give you the simulation code for the errors comming in new release, then also I will try to come up with the scenarios we are facing issues with new Aspose.Cells V2.0.

Thank You.
Kailas

Hi,

We did provide Cells.getCells() in the new fix 2.0.0.x for your need. How could we provide a new API to some older version, we cannot go against our internal policies. The new APIs are incorporated to the latest version/fix of that time. Could you elaborate which issues you have found in the latest fix we provided you. We will be happy to figure them out asap (if we find the issue)

We appreciate if you could create a sample test app to show/simulate the issue(s) you are contracting. It will help us really to figure out the issue soon.

Thank you.

Hi Amjad,

Please find the attached sample simulation program, which will give you NullPointerException with new Aspose.Cells, which was not throwm in case of old Aspose.Cells versions.

Thank You.
Kailas


Hi Kailas,

Thanks for providing us the simulation program,

We found the issue as you have described, we will figure it out and provide you a fix soon.

Thank you.

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

Please try the attached latest fix. For NamedRange.getCells(), it will instantiate Cell object for those cells in the range that were null. Thus the returned array is filled with Cell object and none element is null, and the code, like your example, can succeeds.

But if user want only access Cell's type and value in given range, it is unnecessary to instantiate all empty cells, because all instantiated empty cells will retain in the Workbook data model, that will cause a bit more performance burden. So, we have provided an overloaded method for Cells.getCells() now, to allow the users to choose whether initialize those un-initialized cells or not.

Please see the following overloaded methods,

Cells.getCells(int startRow, int startColumn, int endRow, int endColumn)

Cells.getCells(int startRow, int startColumn, int endRow, int endColumn, boolean initCell)

The method Cells.getCells(int startRow, int startColumn, int endRow, int endColumn) is same with Cells.getCells(int startRow, int startColumn, int endRow, int endColumn, false) i.e., if there are some empty cells in the range that have not been initialized, those cells will keep un-initialized and the corresponding element in the returned array will be null, thus when user process the returned array, he should check whether one element is null before invoking any API of Cell on it.

Hope this will solve your issue. Thank You & Best Regards,

Hi,

I am getting one issue with this Aspose.CellsV2.0.0.13 jar.
I am not able to simulate this issue out of my project to send you demo program for the issue.

Kindly please share the debug version of Aspose.CellsV2.0.0.13 jar.

Thank You.
Kailas Kore

Hi Kailas,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

Well, we will appreciate if you share the details of the problem you are facing in your application. What kind of error or exception you are getting? So, we can better understand the problem / issue you are facing and provide you a proper solution for that.

Thank You & Best Regards,

I am getting following exception while copying worksheet.

[05 Feb 2009 22:49:52,852] [ RUNDOWN_APP_USER ] [ERROR]-[ReportModelManager-loadWorksheet] - java.lang.NullPointerException
at com.aspose.cells.Column.a(Unknown Source)
at com.aspose.cells.Columns.a(Unknown Source)
at com.aspose.cells.Worksheet.copy(Unknown Source)

Outside the project i am not getting this issue when I tried to copy same worksheets.

Thank You.
Kailas

Hi Kailas,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

Please try the attached fix; this is a debug version for your requirement. We have added some catching code to prevent breaking down the whole application in case of such NullPointerException, please try it and send us the output messages and detail Exception track so we can figure the issue out.

Thank You & Best Regards,

Hi,

This time i didn’t get Null Pointer Exception. But the issue is still there.

I am getting following messages in console.

Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66
Absent style for XF: 66

Kindly look into it.

Thanks.
Kailas

Hi Kailas,

Thank you for providing the details. We will look into your issue and get back to you soon.

Thank You & Best Regards,

Hi Kailas,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

We have built another debug version in which we added some more debug info (attached with the post).Hopefully it will help us to figure out the issue. We need your help to use this debug version and send the output message to us.

Thank you for your support.

Hi Nausherwan,

Please find the debug output attached.

Thank You.
Kailas

Hi Kailas,

Thank you for providing the debug output. We will look into it and get back to you soon.

Thank you for you help and support,