[]
Next we will format the content using styles. The code in this step should be added after the code from Step 2 of 4.
Add the following code to create two new styles: stye1 and style2.
' Add style 1.
Dim style1 As New XLStyle(book)
style1.Font = New XLFont("Tahoma", 9, true, false)
style1.ForeColor = Colors.RoyalBlue
' Add style 2.
Dim style2 As New XLStyle(book)
style2.Font = New XLFont("Tahoma", 9, false, true)
style2.BackColor = Colors.RoyalBlue
style2.ForeColor = Colors.White
// Add style 1.
XLStyle style1 = new XLStyle(book);
style1.Font = new XLFont("Tahoma", 9, true, false);
style1.ForeColor = Colors.RoyalBlue;
// Add style 2.
XLStyle style2 = new XLStyle(book);
style2.Font = new XLFont("Tahoma", 9, false, true);
style2.BackColor = Colors.RoyalBlue;
style2.ForeColor = Colors.White;
Then add the following code to apply the new styles to the content.
For i = 0 To 9
' Apply styles to the content.
If (i + 1) Mod 2 = 0 Then
sheet(i, 0).Style = style2
sheet(i, 1).Style = style1
sheet(i, 2).Style = style2
Else
sheet(i, 0).Style = style1
sheet(i, 1).Style = style2
sheet(i, 2).Style = style1
End If
Next i
for (i = 0; i <= 9; i++)
{
// Apply styles to the content.
if ((i + 1) % 2 == 0)
{
sheet[i, 0].Style = style2;
sheet[i, 1].Style = style1;
sheet[i, 2].Style = style2;
}
else
{
sheet[i, 0].Style = style1;
sheet[i, 1].Style = style2;
sheet[i, 2].Style = style1;
}
}