Hello,
I have a problem with Microsoft.Offic e.Interop.Excel .Range.Group()
method.
The problem is that I can call this method only 7 times, before it
throws me an exception.
I don't understand quite well why this happens, and for witch
documents this affirmation is valid, but the problem exists, probably,
for a large files.
For example, if you save this file - http://serhio.atspace.com/ExcelData.xls
on the drive C, and executes the following code:
(see herea formatted variant of this post:
http://forums.microsoft.com/Forums/S...36692&SiteID=1
)
_______________ _______________ _______________ ___
static void Main(string[] args)
{
Microsoft.Offic e.Interop.Excel .Application excelApp = new
ApplicationClas s();
excelApp.Visibl e = true; // Makes Excel visible to the
user.
string workbookPath = @"C:\ExcelData. xls"; // Add your
own path here
// The following code opens an existing workbook
Workbook excelWorkbook =
excelApp.Workbo oks.Open(workbo okPath, 0,
false, 5, "", "", false, XlPlatform.xlWi ndows, "",
true,
false, 0, true, false, false);
// The following gets the first Woorksheet
Worksheet worksheet = excelWorkbook.W orksheets.get_I tem(1)
as Worksheet;
worksheet.Outli ne.SummaryRow =
XlSummaryRow.xl SummaryAbove;
Range aRange;
int groupCounter = 0;
try
{
for (int i = 10; i < 450; i = i + 11)
{
aRange =
worksheet.get_R ange(string.For mat("C{0}:C{1}" , i, i + 10),
Missing.Value);
aRange.Group(Mi ssing.Value, Missing.Value,
Missing.Value, Missing.Value);
groupCounter++;
}
}
catch (Exception ex)
{
throw ex;
}
}
_______________ _______________ _______________ ___
Is there somebody qho can explain this behavior, and how can I resolve
this issue?
Thanks a lot
/sergiu