ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   write two excel sheet (https://www.excelbanter.com/excel-programming/302604-write-two-excel-sheet.html)

imabegginner

write two excel sheet
 
object missing=Missing.Value;
Excel.Application myExcel = new Excel.Application ( ) ;

myExcel.Application.Workbooks.Open(fileName,missin g,missing,missing,missing,
missing,missing,missing,missing,missing,missing,mi ssing,missing);

Excel.Workbook myBook=myExcel.Workbooks[1];
Excel.Sheets sheets=myBook.Worksheets;

for(int currSheet=1; currSheet < 2; currSheet ++)
{
Excel.Worksheet mySheet=(Excel.Worksheet)sheets.get_Item(currSheet );

//write data, eg::
mySheet.Cells[1,1] = "1";
mySheet.Cells[2,1] = "2";

Excel.Range r=mySheet.get_Range(mySheet.Cells[1,1],mySheet.Cells[2,1]);
r.Select(); //wrong when second loop, Why?
}


All times are GMT +1. The time now is 02:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com