ImportantThe Universal Subscription or an additional Document Server Subscription is required to use this example in production code. Please refer to the DevExpress Subscription page for pricing information.
To get started with the non-visual spreadsheet component, perform the following steps.
-
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.

-
Add references to the following libraries:
- DevExpress.Charts.v17.2.Core.dll
- DevExpress.XtraCharts.v17.2.dll
- DevExpress.Data.v17.2.dll
- DevExpress.Docs.v17.2.dll
- DevExpress.Office.v17.2.Core.dll
- DevExpress.Spreadsheet.v17.2.Core.dll
- DevExpress.Utils.v17.2.dll
-
Paste the code listed below in the Main method of the Program.cs file (Main procedure of the Module1.vb file for Visual Basic).
C# |
using DevExpress.Spreadsheet;
Workbook workbook = new DevExpress.Spreadsheet.Workbook();
Worksheet worksheet = workbook.Worksheets[0];
Cell cell = worksheet.Cells["A1"];
cell.Value = 1;
worksheet.Range["A2:A10"].Formula = "=SUM(A1+1)";
worksheet.Range["B1:B10"].Formula = "=A1+2";
worksheet.Range["C1:C10"].ArrayFormula = "=A1:A10*B1:B10";
workbook.SaveDocument("TestDoc.xlsx", DocumentFormat.OpenXml);
worksheet.PrintOptions.PrintGridlines = true;
workbook.ExportToPdf("TestDoc.pdf");
System.Diagnostics.Process.Start("TestDoc.pdf");
System.Diagnostics.Process.Start("TestDoc.xlsx");
|
VB |
Imports DevExpress.Spreadsheet
Dim workbook As Workbook = New DevExpress.Spreadsheet.Workbook()
Dim worksheet As Worksheet = workbook.Worksheets(0)
Dim cell As Cell = worksheet.Cells("A1")
cell.Value = 1
worksheet.Range("A2:A10").Formula = "=SUM(A1+1)"
worksheet.Range("B1:B10").Formula = "=A1+2"
worksheet.Range("C1:C10").ArrayFormula = "=A1:A10*B1:B10"
workbook.SaveDocument("TestDoc.xlsx", DocumentFormat.OpenXml)
worksheet.PrintOptions.PrintGridlines = True
workbook.ExportToPdf("TestDoc.pdf")
System.Diagnostics.Process.Start("TestDoc.pdf")
System.Diagnostics.Process.Start("TestDoc.xlsx")
|
-
Run the project.
The following image shows the files generated after executing the code above.

See Also