GrapeCity.ActiveReports.Export.Excel.v9 Assembly > GrapeCity.SpreadBuilder Namespace > DDSheet Class : Cells Method |
private void Form1_Load(object sender, System.EventArgs e) { // Add a sheet to the Sheets collection of the Workbook. GrapeCity.SpreadBuilder.Workbook sb = new GrapeCity.SpreadBuilder.Workbook(); sb.Sheets.AddNew(); // Set the properties, values, for columns, rows, and cells. sb.Sheets[0].Name = "Customer Call List"; sb.Sheets[0].Columns(0).Width = 2 * 1440; sb.Sheets[0].Columns(1).Width = 1440; sb.Sheets[0].Columns(2).Width = 1440; sb.Sheets[0].Rows(0).Height = 1440/4; // Header row sb.Sheets[0].Cell(0,0).SetValue("Company Name"); sb.Sheets[0].Cell(0,1).SetValue("Department Name"); sb.Sheets[0].Cell(0,2).SetValue("Phone Number"); // Data for the first row sb.Sheets[0].Cell(1,0).SetValue("Grapecity"); sb.Sheets[0].Cell(1,1).SetValue("Sales Department"); sb.Sheets[0].Cell(1,2).SetValue("(022) 777-8210"); //Specify the cell range and set the format sb.Sheets[0].Cells(sb.Sheets[0].Cell(0, 0), sb.Sheets[0].Cell(0, 2)).FontBold = true; sb.Sheets[0].Cells(sb.Sheets[0].Cell(0, 0), sb.Sheets[0].Cell(1, 2)).FontName = "MS UI Gothic"; // Save the Workbook to an Excel file. sb.Save (Application.StartupPath + @"\x.xls"); MessageBox.Show(Application.StartupPath + @"Saved to" + "\x.xls."); }
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' Add a sheet to the Sheets collection of the Workbook. Dim sb As New GrapeCity.SpreadBuilder.Workbook() sb.Sheets.AddNew() ' Set the properties, values, for columns, rows, and cells. With sb.Sheets(0) .Name = "Customer Call List" .Columns(0).Width = 2 * 1440 .Columns(1).Width = 1440 .Columns(2).Width = 1440 .Rows(0).Height = 1440 / 4 ' Header row .Cell(0, 0).SetValue("Company Name") .Cell(0, 1).SetValue("Department Name") .Cell(0, 2).SetValue("Phone Number") ' Data for the first row .Cell(1, 0).SetValue("Grapecity") .Cell(1, 1).SetValue("Sales Department") .Cell(1, 2).SetValue("(022) 777-8210") End With ' Specify the cell range and set the format sb.Sheets(0).Cells(sb.Sheets(0).Cell(0, 0), sb.Sheets(0).Cell(0, 2)).FontBold = True sb.Sheets(0).Cells(sb.Sheets(0).Cell(0, 0), sb.Sheets(0).Cell(1, 2)).FontName = "MS UI Gothic" ' Save the Workbook to an Excel file. sb.Save(Application.StartupPath & "\x.xls") MsgBox(Application.StartupPath & "Saved to" & "\x.xls") End Sub
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2