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.
Unfortunately, activation email could not send to your email. Please try again.

Populating a range of cells with an object type?

Thread ID:

Created:

Updated:

Platform:

Replies:

53876 Dec 21,2006 02:33 PM Jan 2,2007 08:38 AM ASP.NET Web Forms (Classic) 4
loading
Tags: XlsIO
Ryan
Asked On December 21, 2006 02:33 PM

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

Ryan
Replied On December 21, 2006 02:38 PM

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

Melba Winshia [Syncfusion]
Replied On December 22, 2006 07:26 AM

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

Ryan
Replied On December 27, 2006 12:10 PM

>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

Melba Winshia [Syncfusion]
Replied On January 2, 2007 08:38 AM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;