C# Programming
07-06-2009, 10:40 AM
Hi Guys,
I tried a lot to figure out how to skip writin onto a particular excel cell using C#, but couldnt get the proper logic.
my eg:
*Team Leader (required) abcxyz User1 user2
Customer Interface Focal dfgidf user23 user3*
each of the names above has to be in a particular cell... but in the excel template, first cell (Team Leader (required)) is readonly, so i cant write into that cell, so my final excel sheet should show
abcxyz User1 user2
Customer Interface Focal dfgidf user23 user3.....
.....
i tried various logics for this... please see the code below
1. Microsoft.Office.Interop.Excel.Workbook SelWorkBook = excelappln1.Workbooks.Open(curfile,
0, false, 5, "", "", false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "", true, false, 0, false, false, false);
Microsoft.Office.Interop.Excel.Sheets excelSheets = SelWorkBook.Worksheets;
Microsoft.Office.Interop.Excel.Worksheet excelworksheet = (Microsoft.Office.Interop.Excel.Worksheet)excelSheets.get_Item(CurSheetName);
Microsoft.Office.Interop.Excel.Range excelRange = excelworksheet.UsedRange;
if ((!excelworksheet.Cells[CurTaskNode.DATA_MIN_ROW + minRow, CurTaskNode.DATA_MIN_COL + minCol]).Locked)
{
// Assigning the Value from reader to the particular cell in excel sheet excelworksheet.Cells[CurTaskNode.DATA_MIN_ROW + minRow, CurTaskNode.DATA_MIN_COL + minCol] = values[iValueIndex];
iValueIndex++;
}
but the error shows, in the if statement
Error 1 Operator '!' cannot be applied to operand of type 'object'
so, please say how to handle this case.
Thanks
Ramm
I tried a lot to figure out how to skip writin onto a particular excel cell using C#, but couldnt get the proper logic.
my eg:
*Team Leader (required) abcxyz User1 user2
Customer Interface Focal dfgidf user23 user3*
each of the names above has to be in a particular cell... but in the excel template, first cell (Team Leader (required)) is readonly, so i cant write into that cell, so my final excel sheet should show
abcxyz User1 user2
Customer Interface Focal dfgidf user23 user3.....
.....
i tried various logics for this... please see the code below
1. Microsoft.Office.Interop.Excel.Workbook SelWorkBook = excelappln1.Workbooks.Open(curfile,
0, false, 5, "", "", false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "", true, false, 0, false, false, false);
Microsoft.Office.Interop.Excel.Sheets excelSheets = SelWorkBook.Worksheets;
Microsoft.Office.Interop.Excel.Worksheet excelworksheet = (Microsoft.Office.Interop.Excel.Worksheet)excelSheets.get_Item(CurSheetName);
Microsoft.Office.Interop.Excel.Range excelRange = excelworksheet.UsedRange;
if ((!excelworksheet.Cells[CurTaskNode.DATA_MIN_ROW + minRow, CurTaskNode.DATA_MIN_COL + minCol]).Locked)
{
// Assigning the Value from reader to the particular cell in excel sheet excelworksheet.Cells[CurTaskNode.DATA_MIN_ROW + minRow, CurTaskNode.DATA_MIN_COL + minCol] = values[iValueIndex];
iValueIndex++;
}
but the error shows, in the if statement
Error 1 Operator '!' cannot be applied to operand of type 'object'
so, please say how to handle this case.
Thanks
Ramm