//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); IWorksheet worksheet1 = workbook.ActiveSheet; IWorksheet worksheet2 = workbook.Worksheets.Add(); // Add the original view. workbook.CustomViews.Add("Original", true, true); worksheet1.Range["J12"].Value = 1; worksheet2.Range["J12"].Value = 2; worksheet1.PageSetup.PrintArea = "$C$4:$J$12"; worksheet2.PageSetup.PaperSize = PaperSize.A4; // Add a new view which saves the current page settings of all worksheets. workbook.CustomViews.Add("PrintSetting", true, false); worksheet1.Range["5:6"].Hidden = true; worksheet2.Range["5:6"].Hidden = true; // Add a new view which saves the current hidden rows/columns, filter settings of all worksheets. workbook.CustomViews.Add("HiddenRows", false, true); // Save to an excel file workbook.Save("CustomWorkbookViews.xlsx");
' Create a new Workbook Dim workbook As New Workbook Dim worksheet1 As IWorksheet = workbook.ActiveSheet Dim worksheet2 As IWorksheet = workbook.Worksheets.Add() 'Add the original view. workbook.CustomViews.Add("Original", True, True) worksheet1.Range("J12").Value = 1 worksheet2.Range("J12").Value = 2 worksheet1.PageSetup.PrintArea = "$C$4:$J$12" worksheet2.PageSetup.PaperSize = PaperSize.A4 'Add a New view which saves the current page settings of all worksheets. workbook.CustomViews.Add("PrintSetting", True, False) worksheet1.Range("5:6").Hidden = True worksheet2.Range("5:6").Hidden = True 'Add a New view which saves the current hidden rows/columns, filter settings of all worksheets. workbook.CustomViews.Add("HiddenRows", False, True) ' save to an excel file workbook.Save("CustomWorkbookViews.xlsx")