New workbook in devexpress 13.1

Source: Internet
Author: User

New in devexpress 13.1Workbook documentation APIWith this API,No need to install Microsoft ExcelYou can create various workbooks!

The spreadsheet Document Server is a powerful and non-visual file server.. Net Library, which is used to create and manage local workbooks. Most importantly, Microsoft Excel is not required locally. With this intuitive spreadsheet API, you can create invoices, reports, payment schedules, and a large number of types of documents for ease!

Preparation

Before creating a project, we need to add four assembly references to the project. You can find references in GAC or find references in the default installation directory, such as c: \ Program Files (x86) \ devexpress \ dxperience 13.1 \ bin \ framework.

1. Assembly reference

Devexpress. spreadsheet. Workbook is used to represent the main project of the document. Workbook is used to access the top level of a document. Options and styles can be applied to the top level of the document, and worksheets can be accessed.

Each workbook contains multiple worksheets, and workshee has multiple cells.

2. Workbook Structure

The following example shows how to create the most basic XLSX file.

123 Workbook book =
new Workbook();book.Worksheets[0].Cells["B2"].Value =
"Hello World";book.SaveDocument(@"Document.xlsx");<br>

3. Preview The "Hello World" document in Microsoft Excel

Process Cells

In the above example, you may have noticed that accessing or updating cells is very intuitive. The worksheet cell can be referenced either by naming sequence or by coordinates:

12 Workbook book =
new Workbook();book.Worksheets[0].Cells[0, 0].Value = 42;

Note: The direct coordinate starts from 0.

Cell values support all default initial types: boolean values, text, and numbers. The built-in manager ensures that the value type is correct.

12345678 book.Worksheets[0].Cells["B2"].Value = DateTime.Now;book.Worksheets[0].Cells["B2"].NumberFormat =
"m/d/yy";book.Worksheets[0].Cells["B3"].Value = Math.PI;book.Worksheets[0].Cells["B4"].Value =
"Text value...";book.Worksheets[0].Cells["B5"].Value =
true;book.Worksheets[0].Cells["B6"].Value =
float.MaxValue;book.Worksheets[0].Cells["B7"].Value =
'a';book.Worksheets[0].Cells["B8"].Value = Int32.MaxValue;

Cell format

Each worksheetcell uses the formatting interface to publish its format:

123456 public
interface
Formatting {    Alignment Alignment {
get; }    Borders Borders {
get; }    Fill Fill {
get; }    Font Font {
get; }}

The following example shows how to set various cell options:

123456 book.Worksheets[0].Cells["B2"].Value =
"...Text value";book.Worksheets[0].Cells["B2"].Alignment.Horizontal = HorizontalAlignment.Right;book.Worksheets[0].Cells["B2"].Borders.SetAllBorders(Color.Orange, BorderLineStyle.Thick);book.Worksheets[0].Cells["B2"].Fill.BackgroundColor = Color.WhiteSmoke;book.Worksheets[0].Cells["B2"].Font.Name =
"Vivaldi";book.Worksheets[0].Cells["B2"].Font.Color = Color.Navy;

  • Devexpress 2013.1 highlights: Workbook documentation API (2)
  • Devexpress 2013.1 highlights: Workbook documentation API (3)

This article Reprinted from http://www.evget.com/zh-CN/Info/catalog/19127.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.