// Create a pdf file stream using FileStream outputStream = new FileStream("CustomBorder.pdf", FileMode.Create); //create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); var templateFile = this.GetResourceStream("xlsx\\CustomBorderStyle.xlsx"); workbook.Open(templateFile); // Customizing the border style for exporting to PDF. var pdfSaveOptions = new PdfSaveOptions(); var thinBorderSetting = new CustomBorderStyle { BorderWidth = 0.4 }; var middleBorderSetting = new CustomBorderStyle { BorderWidth = 1.5 }; var dashBorderSetting = new CustomBorderStyle { BorderWidth = 0.4, Dashes = new List<double> { 0.8, 0.8 } }; pdfSaveOptions.BorderOptions.Add(BorderLineStyle.Thin, thinBorderSetting); pdfSaveOptions.BorderOptions.Add(BorderLineStyle.Medium, middleBorderSetting); pdfSaveOptions.BorderOptions.Add(workbook.ActiveSheet.Range["B13"].Borders[BordersIndex.EdgeTop].LineStyle, dashBorderSetting); //Save the workbook into pdf file. workbook.Save(outputStream, pdfSaveOptions); // close the pdf stream outputStream.Close();
' Create a pdf file stream Dim outputStream = File.Create("CustomBorder.pdf") ' Create a new Workbook Dim workbook As New Workbook Dim templateFile = GetResourceStream("xlsx\CustomBorderStyle.xlsx") workbook.Open(templateFile) Dim pdfSaveOptions = New PdfSaveOptions() Dim thinBorderSetting = New CustomBorderStyle With { .BorderWidth = 0.4 } Dim middleBorderSetting = New CustomBorderStyle With { .BorderWidth = 1.5 } Dim dashBorderSetting = New CustomBorderStyle With { .BorderWidth = 0.4, .Dashes = New List(Of Double) From { 0.8, 0.8 } } pdfSaveOptions.BorderOptions.Add(BorderLineStyle.Thin, thinBorderSetting) pdfSaveOptions.BorderOptions.Add(BorderLineStyle.Medium, middleBorderSetting) pdfSaveOptions.BorderOptions.Add(workbook.ActiveSheet.Range("B13").Borders(BordersIndex.EdgeTop).LineStyle, dashBorderSetting) workbook.Save(outputStream, pdfSaveOptions) ' close the pdf stream outputStream.Close()