How to disable gridlines in Excel using open xml C#?

后端 未结 2 362
不思量自难忘°
不思量自难忘° 2021-01-14 18:41

I want to disable GridLines in excel and put custom borders to excel cells using open xml in C#

I have tried with below code but is throwing exception when i open th

2条回答
  •  醉梦人生
    2021-01-14 19:18

    The WorkbookViewId property of the SheetView class is a required attribute/property. Try this:

    SheetView sheetView = new SheetView();
    sheetView.ShowGridLines = new BooleanValue(false);
    sheetView.WorkbookViewId = 0;
    sheetViews.Append(sheetView);
    ws.Append(sheetViews);
    

    That uses the 1st (default) workbook view. Don't worry, you don't have to explicitly create a WorkbookView child of the BookViews class, which is a child of Workbook. Unless you want to, of course. :)

提交回复
热议问题