C# Create Excel workbook with 1 sheet by default

前端 未结 2 1594
醉梦人生
醉梦人生 2021-02-19 18:13

I\'m trying to create an Excel file with C# COM interop but seems it create it by default with 3 sheets instead of empty or only one. What is needed to create it Empty or just

2条回答
  •  星月不相逢
    2021-02-19 19:12

    Excel.Application xl = null;
    Excel._Workbook wb = null;
    
    xl = new Excel.Application();
    xl.SheetsInNewWorkbook = 1;
    xl.Visible = true;
    
    wb = (_Workbook)(xl.Workbooks.Add(Missing.Value));
    

提交回复
热议问题