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.