Updating Excel Sheet

  • Thread starter Thread starter trialproduct2004
  • Start date Start date
T

trialproduct2004

Hi all
i am having application storing data in excel sheet.
This applicaton is in C# .net.
I want to update rows of excel sheet in C#.
Can some one help me how to do it.
please help me.
Thanks in advance.
 
These are some helpful methods that may help you
private void setCellValue(ref Excel._Worksheet objSheet, int rowIndex,
int columnIndex,string cellValue)
{
Excel.Range objCells = objSheet.Cells;
Excel.Range objCell = (Excel.Range)objCells[rowIndex,columnIndex];
objCell.Value2 = cellValue;
releaseComObj(objCell);
releaseComObj(objCells);
}
private void setCellFontSize(ref Excel._Worksheet objSheet, int
rowIndex, int columnIndex,int fontSize)
{
Excel.Range objCells = objSheet.Cells;
Excel.Range objCell = (Excel.Range)objCells[rowIndex,columnIndex];
Excel.Font objFont = objCell.Font;
objFont.Size = fontSize;
releaseComObj(objFont);
releaseComObj(objCell);
releaseComObj(objCells);
}
private void setCellFontBold(ref Excel._Worksheet objSheet, int
rowIndex, int columnIndex,bool boldFont)
{
Excel.Range objCells = objSheet.Cells;
Excel.Range objCell = (Excel.Range)objCells[rowIndex,columnIndex];
Excel.Font objFont = objCell.Font;
objFont.Bold = true;
releaseComObj(objFont);
releaseComObj(objCell);
releaseComObj(objCells);
}


private void releaseComObj(object o)
{
try
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(o);
}
catch {}
finally
{
o = null;
}
}
 
Back
Top