//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); IWorksheet activeSheet = workbook.ActiveSheet; // Fill data var testData = new object[,] { { "Fruit", null, null, "Fruit Total", "Vegetables", null, null, null, "Vegetables Total", "Grand Total"}, { "Canada", "Germany", "New Zealand", null, "Australia", "Germany", "United Kingdom", "United States", null, null}, { 7431d, null, null, 9848d, null, null, null, null, null, 9848d}, { 8384d, 8250d, 6906d, 24157d, null, null, null, null, null, 24157d}, { null, null, null, null, null, 2626d, null, null, 2626d, 2626d}, { null, null, null, null, 9062d, null, 8239d, 7012d, 24313d, 24313d}, { null, null, null, null, null, 1903d, null, 4270d, 6173d, 6173d}, { null, null, null, 3610d, null, null, null, null, null, 3610d}, { 15815d, 8250d, 6906d, 30971d, 9062d, 4529d, 8239d, 11282d, 33112d, 64083d} }; IRange dataAndHeader = activeSheet.Range["$A$1:$J$9"]; dataAndHeader.Value = testData; // Add borders var borders = dataAndHeader.Borders; borders.LineStyle = BorderLineStyle.Thin; borders.ThemeColor = ThemeColor.Dark1; borders.TintAndShade = -0.499984740745262; // Use center across selection in the header row IRange header = activeSheet.Range["$A$1:$J$1"]; header.HorizontalAlignment = HorizontalAlignment.CenterContinuous; activeSheet.Columns.AutoFit(); activeSheet.PageSetup.Orientation = PageOrientation.Landscape; // Save to a pdf file workbook.Save("CenterAcrossSelection.pdf");
' Create a new Workbook Dim workbook As New Workbook Dim activeSheet As IWorksheet = workbook.ActiveSheet ' Fill data Dim testData(,) As Object = { {"Fruit", Nothing, Nothing, "Fruit Total", "Vegetables", Nothing, Nothing, Nothing, "Vegetables Total", "Grand Total"}, {"Canada", "Germany", "New Zealand", Nothing, "Australia", "Germany", "United Kingdom", "United States", Nothing, Nothing}, {7431.0, Nothing, Nothing, 9848.0, Nothing, Nothing, Nothing, Nothing, Nothing, 9848.0}, {8384.0, 8250.0, 6906.0, 24157.0, Nothing, Nothing, Nothing, Nothing, Nothing, 24157.0}, {Nothing, Nothing, Nothing, Nothing, Nothing, 2626.0, Nothing, Nothing, 2626.0, 2626.0}, {Nothing, Nothing, Nothing, Nothing, 9062.0, Nothing, 8239.0, 7012.0, 24313.0, 24313.0}, {Nothing, Nothing, Nothing, Nothing, Nothing, 1903.0, Nothing, 4270.0, 6173.0, 6173.0}, {Nothing, Nothing, Nothing, 3610.0, Nothing, Nothing, Nothing, Nothing, Nothing, 3610.0}, {15815.0, 8250.0, 6906.0, 30971.0, 9062.0, 4529.0, 8239.0, 11282.0, 33112.0, 64083.0} } Dim dataAndHeader As IRange = activeSheet.Range("$A$1:$J$9") dataAndHeader.Value = testData ' Add borders With dataAndHeader.Borders .LineStyle = BorderLineStyle.Thin .ThemeColor = ThemeColor.Dark1 .TintAndShade = -0.499984740745262 End With ' Use center across selection in the header row Dim header As IRange = activeSheet.Range("$A$1:$J$1") header.HorizontalAlignment = HorizontalAlignment.CenterContinuous activeSheet.Columns.AutoFit() activeSheet.PageSetup.Orientation = PageOrientation.Landscape ' save to a pdf file workbook.Save("CenterAcrossSelection.pdf")