Tuesday, 05 April 2011 09:25

PDF TextLayout in C#, VB.NET

The sample demonstrates how to work with text layout in PDF document.

Download TextLayout.pdf

Published in Formating
Tuesday, 05 April 2011 09:07

PDF Font in C#, VB.NET

The sample demonstrates how to work with font in PDF document.

Download Font.pdf

Published in Formating
Tuesday, 05 April 2011 07:42

PDF Graphics Transparency in C#, VB.NET

The sample shows the different modes of transparency.

Download Transparency.pdf

Published in Drawing
Tuesday, 05 April 2011 07:27

PDF Barcode in C#, VB.NET

The sample demonstrates how to draw barcode in PDF document.

Download Barcode.pdf

Published in Drawing
Tuesday, 05 April 2011 07:21

PDF DrawImage in C#, VB.NET

The sample demonstrates how to draw image in PDF document.

Download DrawImage.pdf

Published in Drawing
Tuesday, 05 April 2011 07:19

PDF DrawShape in C#, VB.NET

The sample demonstrates how to draw shape to a PDF document.

Download DrawShape.pdf

Published in Drawing
Tuesday, 05 April 2011 07:12

PDF DrawText in C#, VB.NET

The sample demonstrates how to draw text to a PDF document.

Download DrawText.pdf

Published in Drawing
Tuesday, 05 April 2011 06:47

PDF Image in C#, VB.NET

The sample demonstrates how to insert an image to a PDF document.

Download Image.pdf

Published in Quick Guide
Friday, 01 April 2011 08:52

PDF HelloWorld in C#, VB.NET

The sample demonstrates how to write a "HelloWorld" to a PDF document.

Download HelloWorld.pdf

Published in Quick Guide
Wednesday, 05 January 2011 08:37

Add Excel Borders in C#, VB.NET

In Excel, you can add borders to individual cells to emphasize data, mark summarized values, or separate data in cell ranges. Borders can also be formatted with different line styles and colors. This article presents how we can apply border styles to Excel cells using Spire.XLS.

Step 1: Create a Workbook instance and get the first worksheet.

Workbook wb = new Workbook();
Worksheet sheet = wb.Worksheets[0];

Step 2: Get the cell range where you want to apply border style.

CellRange range = sheet.Range["B2:D4"];

Step 3: Call BorderInside() and BorderAround() methods to apply styles to borders inside and around the range. To add a border to the top, bottom, left and right, use the Borders[BordersLineType.EdgeTop].LineStyle property, Borders[BordersLineType.EdgeBottom].LineStyle property and alike.

range.BorderInside(LineStyleType.Thin, Color.Blue);
range.BorderAround(LineStyleType.Medium, Color.Blue);

Step 4: Save to file.

wb.SaveToFile("result.xlsx", ExcelVersion.Version2013);

Output:

Add Excel Borders in C#, VB.NET

Full Code:

[C#]
Workbook wb = new Workbook();
Worksheet sheet = wb.Worksheets[0];

//apply border style to the range B2:D4
CellRange range = sheet.Range["B2:D4"];
range.BorderInside(LineStyleType.Thin, Color.Blue);
range.BorderAround(LineStyleType.Medium, Color.Blue);

//apply border style to the range D7:F9
range = sheet.Range["D7:F9"];
range.Borders.LineStyle = LineStyleType.Double;
range.Borders[BordersLineType.DiagonalDown].LineStyle = LineStyleType.None;
range.Borders[BordersLineType.DiagonalUp].LineStyle = LineStyleType.None;

//apply border style to the range F12:H14
range = sheet.Range["F12:H14"];
range.Merge();
range.BorderAround(LineStyleType.Thin);
range.Borders[BordersLineType.DiagonalDown].LineStyle = LineStyleType.Thin;
range.Borders[BordersLineType.EdgeBottom].LineStyle = LineStyleType.Thick;  
range.Borders.Color = Color.Red;

wb.SaveToFile("result.xlsx", ExcelVersion.Version2013);
[VB.NET]
Dim wb As Workbook = New Workbook()
Dim sheet As Worksheet = wb.Worksheets(0)
 
'apply border style to the range B2:D4
Dim range As CellRange = sheet.Range("B2:D4")
range.BorderInside(LineStyleType.Thin, Color.Blue)
range.BorderAround(LineStyleType.Medium, Color.Blue)
 
'apply border style to the range D7:F9
range = sheet.Range("D7:F9")
range.Borders.LineStyle = LineStyleType.Double
range.Borders(BordersLineType.DiagonalDown).LineStyle = LineStyleType.None
range.Borders(BordersLineType.DiagonalUp).LineStyle = LineStyleType.None
 
'apply border style to the range F12:H14
range = sheet.Range("F12:H14")
range.Merge()
range.BorderAround(LineStyleType.Thin)
range.Borders(BordersLineType.DiagonalDown).LineStyle = LineStyleType.Thin
range.Borders(BordersLineType.EdgeBottom).LineStyle = LineStyleType.Thick
range.Borders.Color = Color.Red

wb.SaveToFile("result.xlsx", ExcelVersion.Version2013)
Published in Cells
Page 4 of 10