Skip to main content
A newer version of this page is available. .

Getting Started

  • 3 minutes to read

Important

You require a license to the DevExpress Office File API or DevExpress Universal Subscription to use these examples in production code. Refer to the DevExpress Subscription page for pricing information.

To get started with the non-visual spreadsheet component, perform the following steps.

  1. Start Visual Studio and create a new Console Application project by selecting FILE | New | Project… in the main menu. In the New Project window that is invoked, select Console Application, specify the name of the project, and click OK.

    Spreadsheet_CreateNewProject

  2. Add references to the following libraries:

    • DevExpress.Charts.v18.2.Core.dll
    • DevExpress.Data.v18.2.dll
    • DevExpress.DataAccess.v18.2.dll
    • DevExpress.Docs.v18.2.dll
    • DevExpress.Office.v18.2.Core.dll
    • DevExpress.Pdf.v18.2.Core.dll
    • DevExpress.Printing.v18.2.Core.dll
    • DevExpress.Sparkline.v18.2.Core.dll
    • DevExpress.Spreadsheet.v18.2.Core.dll
    • DevExpress.XtraCharts.v18.2.dll
  3. Paste the code listed below in the Main method of the Program.cs file (Main procedure of the Module1.vb file for Visual Basic).

    using DevExpress.Spreadsheet;
    // ...
    
    // Create an instance of a workbook.
    Workbook workbook = new DevExpress.Spreadsheet.Workbook();
    
    // Access the first worksheet in the workbook.
    Worksheet worksheet = workbook.Worksheets[0];
    
    // Access the "A1" cell in the worksheet.
    Cell cell = worksheet.Cells["A1"];
    
    // Specify the "A1" cell value.
    cell.Value = 1;
    
    // Fill cells with sequential numbers by using shared formulas.
    worksheet.Range["A2:A10"].Formula = "=SUM(A1+1)";
    worksheet.Range["B1:B10"].Formula = "=A1+2";
    
    // Multiply values contained in the cell range A1 through A10 
    // by the corresponding values contained in B1 through B10,
    // and display the results in cells C1 through C10.
    worksheet.Range["C1:C10"].ArrayFormula = "=A1:A10*B1:B10";
    
    // Save the document file under the specified name.
    workbook.SaveDocument("TestDoc.xlsx", DocumentFormat.OpenXml);
    
    // Display gridlines in PDF.
    worksheet.PrintOptions.PrintGridlines = true;
    
    // Export the document to PDF.
    workbook.ExportToPdf("TestDoc.pdf");
    
    // Open the PDF document using the default viewer..
    System.Diagnostics.Process.Start("TestDoc.pdf");
    
    // Open the XLSX document using the default application.
    System.Diagnostics.Process.Start("TestDoc.xlsx");
    
  4. Run the project.

The following image shows the files generated after executing the code above.

Getting_started

See Also