Hello Team,
Can you please advice me how to access newly created workbook i.e. ActiveWorkbook?
Regards,
Manish
Hi,
{
Workbook wb = new Workbook(“a.xlsx”);
curWrkbk = wb; //here you have assigned the local workbook reference to class scope workbook reference.
Thanks for Reply Shakeel.
But I am talking about how to access a newly created workbook, that is not saved yet.
{
curWrkbk = ActiveWorkbook; </font><font color="#006400">//here you have assigned the local workbook reference to class scope workbook reference.</font><font color="#800080">
Regards,
Manish
Hi,
In short, you can get your active workbook from List collection object by providing it the active workbook index.
{
List lst = new List();
static void Main(string[] args)
{
Program pg = new Program();
pg.CreateWorkbookObjects();
//Add worksheet in 3rd workbook and cell data in A5
pg.AddWorksheetInWorkbook(2, "MySheet3");
pg.AddCellDataInWorkbook(2, "MySheet3", "A5", "This is 3rd Workbook.");
//Add worksheet in 5th workbook and cell data in A5
pg.AddWorksheetInWorkbook(4, "MySheet5");
pg.AddCellDataInWorkbook(4, "MySheet5", "C10", "This is 5th Workbook.");
//Add worksheet in 8th workbook and cell data in A5
pg.AddWorksheetInWorkbook(7, "MySheet8");
pg.AddCellDataInWorkbook(7, "MySheet8", "J9", "This is 8th Workbook.");
//Select which of the workbook you want to save
int idx;
idx = 2;
//idx = 4;
//idx = 7;
//Save the selected workbook
pg.SaveWorkbook(idx, "TestOutput.xlsx");
}
//Create 10 workbook objects
void CreateWorkbookObjects()
{
//Create 10 workbook objects
for(int i=0; i<10; i++)
{
Workbook wb = new Workbook();
lst.Add(wb);
}
}
//Add worksheet in your given workbook
void AddWorksheetInWorkbook(int wbIdx, string sheetName)
{
Workbook wb = lst[wbIdx];
wb.Worksheets.Add(sheetName);
}
void AddCellDataInWorkbook(int wbIdx, string sheetName, string cellName, string cellData)
{
Workbook wb = lst[wbIdx];
wb.Worksheets[sheetName].Cells[cellName].PutValue(cellData);
}
void SaveWorkbook(int wbIdx, string wbName)
{
Workbook wb = lst[wbIdx];
wb.Save(wbName);
}
Hi Expert,
Actually i am trying to make one separate com-addins which will only work for create presentation using aspose. which will call on a menu button click of Active workbook.
I do not need to create a new workbook using Aspose.
Regards,
Manish
Hi,
i am trying to make one separate com-addins