C # commonly used Excel methods and attributes for Excel operations zz

Source: Internet
Author: User

When generating an excel file, you sometimes need to set some cell attributes. For details, refer:
Range. NumberFormatLocal = "@"; // set the cell format to text.

Range = (Range) worksheet. get_Range ("A1", "E1"); // obtain multiple cells in Excel. In this example, the table is used as the Excel header.

Range. Merge (0); // cell Merge action

Worksheet. Cells [1, 1] = "Excel cell assignment"; // Excel cell assignment

Range. Font. Size = 15; // set the Font Size.

Range. Font. Underline = true; // you can specify whether the Font contains underscores.

Range. Font. Name = ""; set the Font type

Range. HorizontalAlignment = XlHAlign. xlHAlignCenter; // you can specify the font type in a cell.

Range. ColumnWidth = 15; // you can specify the cell width.

Range. Cells. Interior. Color = System. Drawing. Color. FromArgb (255,204,153). ToArgb (); // you can specify the background Color of a cell.

Range. Borders. LineStyle = 1; // you can specify the Border width of a cell.

Range. BorderAround (XlLineStyle. xlContinuous, XlBorderWeight. xlThick, XlColorIndex. xlColorIndexAutomatic, System. Drawing. Color. Black. ToArgb (); // border the cell

Range. EntireColumn. AutoFit (); // automatically adjusts the column width.

Range. HorizontalAlignment = xlCenter; // horizontal text center Mode

Range. verticalignment = xlCenter // text vertical center Mode

Range. WrapText = true; // Text wrap

Range. Interior. ColorIndex = 39; // fill color is lavender

Range. Font. Color = clBlue; // Font Color

XlsApp. DisplayAlerts = false; // when saving the Excel file, the Save or not window is not displayed and saved directly.

Workbook. SaveCopyAs (temp);/*** // enter the information and save it to the path and file name.

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.