OWC10.Range.set_Value (with Array)

M

Mike Holloway

I will try another version of same problem. Perhaps some
MS pros will take pity. I have certainly sent them
enough cash for products.

private void ExportDataToExcel(string strPath,
string strFileName,
string [,] arrSheet1,
int maxCols,
int maxRows)
{
string strTest = "'This sucks','This really
sucks', 10, 5000";
OWC10.Spreadsheet xlsheet = new OWC10.Spreadsheet
();

xlsheet.ActiveSheet.Protection.Enabled = false;
OWC10.Range m_objRange = xlsheet.get_Range
(xlsheet.ActiveSheet.Cells[2,1],xlsheet.ActiveSheet.Cells
[maxRows,maxCols]);
m_objRange.ClearContents ();
m_objRange.Activate ();
// TEST STRING -- This does not throw an
exception BUT it puts the entire
// string in every cell in the range. I assume
there is some way to form
// a string that EXCEL can interpret (i.e. characters to
represent row and
// cell boundaries) I just haven't found it yet. There
is NO DOCUMENTATION FOR set_Value
m_objRange.set_Value
(OWC10.XlRangeValueType.xlRangeValueDefault , strTest);

// Everything says this should work but it DOES NOT
// THIS IS WHAT I REALLY WANT TO DO BUT IT ALWAYS THROWS
EXCEPTION "Memory is locked" on THIS LINE (.set_Value)
// m_objRange.set_Value
(OWC10.XlRangeValueType.xlRangeValueDefault, arrSheet1);

// Works from here on
// save it off to the filesystem...
xlsheet.Export(strPath +
strFileName,OWC10.SheetExportActionEnum.ssExportActionNone
,

OWC10.SheetExportFormat.ssExportHTML);
// set content header so browser
knows you'r sending Excel workbook...

Response.ContentType="application/x-msexcel" ;
// stream it on out!
Response.WriteFile(strPath +
strFileName);

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top