我编写了以下调用Excel宏的c#代码。它运行时没有任何错误,但更改不会反映在Excel中。
这是c#代码
return new List<Model<T>>(GetRoles());
这是我从上面代码中调用的宏
private void button1_Click(object sender, EventArgs e)
{
Excel.Application xlApp = new Excel.Application();
Excel.Workbook xlWorkBook;
//~~> Start Excel and open the workbook.
//xlWorkBook = xlApp.Workbooks.Open("E:\\Users\\Siddharth Rout\\Desktop\\book1.xlsm");
xlWorkBook = xlApp.Workbooks.Open("D:\\Excel\\Excel.xlsm");
Excel.Worksheet sheet = (Excel.Worksheet)xlWorkBook.Worksheets[1];
Console.WriteLine(sheet.Name);
sheet.Activate();
string name = xlApp.ActiveSheet.Name;
//~~> Run the macros by supplying the necessary arguments
xlApp.Run("italicize");
//~~> Clean-up: Close the workbook
xlWorkBook.Close(false);
//~~> Quit the Excel Application
xlApp.Quit();
//~~> Clean Up
releaseObject(xlApp);
releaseObject(xlWorkBook);
}