C
Code Deaf
I'm getting an error in my c# app when trying to insert a block of text from
a string array into an Excel cell.
The line of code which reads the string goes like this:
FSInfo[2] = FSPage.Substring(pos3 + 148, k - pos3 - 147);
This line assigns a substring of length (k - pos3 - 147) to a string array
FSInfo[], starting at position pos3 + 148.
The line which generates the error is the set_Value line in this block,
which tries to write the substring into Excel:
public bool InsertDataAt(string start, string[,] data)
{
ExcelCOM.Range theCells = MyWorksheet.get_Range(start,
typeMissing);
theCells.set_Value(Type.Missing, data);
return true;
}
The error reads:
System.Runtime.InteropServices.COMException was unhandled
Message="Exception from HRESULT: 0x800A03EC"
Source=""
ErrorCode=-2146827284
I see from a search of various forums that this error apparently can happen
if there are more than 911 (how about that?) characters in the string; and,
when I test, it works fine if I substitute a number of 911 or less for the
"length" part of the code, k - pos3 - 147.
I'm using Office 2003, with SP2 installed.
Does anyone know if there is a solution for this, other than breaking the
string into chunks of 911 characters or less?
a string array into an Excel cell.
The line of code which reads the string goes like this:
FSInfo[2] = FSPage.Substring(pos3 + 148, k - pos3 - 147);
This line assigns a substring of length (k - pos3 - 147) to a string array
FSInfo[], starting at position pos3 + 148.
The line which generates the error is the set_Value line in this block,
which tries to write the substring into Excel:
public bool InsertDataAt(string start, string[,] data)
{
ExcelCOM.Range theCells = MyWorksheet.get_Range(start,
typeMissing);
theCells.set_Value(Type.Missing, data);
return true;
}
The error reads:
System.Runtime.InteropServices.COMException was unhandled
Message="Exception from HRESULT: 0x800A03EC"
Source=""
ErrorCode=-2146827284
I see from a search of various forums that this error apparently can happen
if there are more than 911 (how about that?) characters in the string; and,
when I test, it works fine if I substitute a number of 911 or less for the
"length" part of the code, k - pos3 - 147.
I'm using Office 2003, with SP2 installed.
Does anyone know if there is a solution for this, other than breaking the
string into chunks of 911 characters or less?