QuickStart: Excel for Silverlight > Step 2 of 4: Adding Content to a C1XLBook |
In the button1_Click event we created in step 1, add the following code to create the book and its content so it looks like the following:
Visual Basic |
Copy Code
|
---|---|
Private Sub button1_Click(sender As Object, e As RoutedEventArgs) SaveBook(Function(book) Dim i As Integer Dim sheet As C1.Silverlight.Excel.XLSheet = book.Sheets(0) For i = 0 To 9 sheet(i, 0).Value = (i + 1) * 10 sheet(i, 1).Value = (i + 1) * 100 sheet(i, 2).Value = (i + 1) * 1000 Next End Function) End Sub |
C# |
Copy Code
|
---|---|
private void button1_Click(object sender, RoutedEventArgs e) { SaveBook(book => { int i; C1.Silverlight.Excel.XLSheet sheet = book.Sheets[0]; for (i = 0; i <= 9; i++) { sheet[i, 0].Value = (i + 1) * 10; sheet[i, 1].Value = (i + 1) * 100; sheet[i, 2].Value = (i + 1) * 1000; } }); } |
You'll notice a call to the SaveBook method. We'll add the code for this method in the next step.