We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Populating a range of cells with an object type?

Is it possible to populate a range of cells with the data contained within an object type?

I'm trying to do so however when I do this, instead of displaying the propper text, each cell contains the text "System.Object[,]".

I'm creating my range as follows:
----------------------------------------
Object[,] data;
IRange range;

data = new Object[2, 10];
<>
range = sheet.Range(1,1,2,10);
range.Value2 = data;
-----------------------------------------

As I said, as a result of this code, each cell within the range contains the text "System.Object[,]".

This code is usable when utilizing the "Microsoft Office 11.0 Control Library" so I was just curious if using an object type in XlsIO is possible.

Thanks.

-Ryan

4 Replies

RY Ryan December 21, 2006 07:38 PM UTC

Ooops. It seems this forum removed my text I had between my "<" tags. Here's my code again:
------------------------------------------
Object[,] data;
IRange range;
data = new Object[2, 10];
(code to fully populate "data" object here)
range = sheet.Range(1,1,2,10);
range.Value2 = data;
------------------------------------------
Also, I have double checked my "data" object and have ensured there is in fact valid data contained within it.

Thanks again.

-Ryan


MW Melba Winshia Syncfusion Team December 22, 2006 12:26 PM UTC

Hi Ryan,

Could you please provide more details on how this can be done in Microsoft Office 11.0 Control Library. This would help us in investigating further on this issue.

Thanks,
Melba


RY Ryan December 27, 2006 05:10 PM UTC

>Hi Ryan,

Could you please provide more details on how this can be done in Microsoft Office 11.0 Control Library. This would help us in investigating further on this issue.

Thanks,
Melba


Sure.

I've provided a sample below. This sample basically displays all of our data for a report. All of our database data is contained within a dataView (which we've named "dataView"). We then use a "for" loop to place all data from this dataView into our data Object. Finally, we utilize the "Microsoft Office 11.0 Control Library" to add this data to an excel worksheet:
------------------------------------------------
private void AddDetail()
{
Object[,] data;
Microsoft.Office.Interop.Excel.Range range;

int currentColumn = 1;
int currentRow = 1;

data = new Object[dataView.Count, 6]; //6 columns & x number of rows

// Data View Sorting
dataView.Sort = "field1Id";

for (int i = 0; i < dataView.Count; i++)
{
data[i, 0] = dataView[i]["field2"];
data[i, 1] = dataView[i]["field3"];
data[i, 2] = dataView[i]["field4"];
data[i, 3] = dataView[i]["field5"];
data[i, 4] = dataView[i]["field6"];
data[i, 5] = dataView[i]["field7"];
}

// Formatting
range = Worksheet.get_Range(Worksheet.Cells[currentRow, currentColumn], Worksheet.Cells[currentRow + dataView.Count - 1, 6]);
range.Font.Size = "8";
range.Font.Name = "Verdana";
range.RowHeight = 14.25;
range.Value2 = data;
}
----------------------------------------------
Based on this, the data will print within the specified range.

Thanks again.

-Ryan


MW Melba Winshia Syncfusion Team January 2, 2007 01:38 PM UTC

Hi Ryan,

Sorry for the delay in getting back to you. Thank you for the detailed explanation. Essential XlsIO do not provide support to populate a range of cells with the data contained within an object type. Sorry for the inconvenience. Please let me know if you have any other questions.

Thanks,
Melba

Loader.
Live Chat Icon For mobile
Up arrow icon