Python operations Excel

Source: Internet
Author: User

Xlutils used to modify Excel, XLWT cannot be used to modify Excel files, only new Excel files can be created

Xlrdbook (Class) returned by Xlrd.open_work ("Example.xls")

Number of Nsheets:sheets
Sheet_names:sheet Name list
Sheets:sheet List
Sheet_by_index (SHEETX): Extract sheet by serial number
Sheet_by_name (Sheet_name): Extract by name sheet

Sheet (Class) is returned by the book object-related method

Name:sheet Name
Nrows: Number of rows
Ncols: Number of columns
Cell (ROWX,COLX): Row rows Colx column cells
Cell_type (ROWX,COLX): Data type
Cell_value (ROWS,COLX): Numeric
Col (Colx): List of all cells in column Colx
Col_slice (Colx,start_rowx=0,end_rowx=none): Section colx column specifies a list of cells
Col_types (Colx,start_rowx=0,end_rowx=none): Section colx column specifies a list of cell numeric types
Col_values (colx,start_rowx=0,end_rowx=none): column COLX Specifies a list of cell values
Row also has various actions of COL, omitted here

The Cell (Class) is returned by sheet object (s)-related methods

CType: A variable of type int that corresponds to a different numeric type
Value: Cell values

Xlwtworkbook (Class) by XLWT. Workbook () returns

Encoding: Encoding Scheme
Add_sheet (sheet_name): Add sheet
Get_sheet (sheet_name): Select sheet
Save (file_name): Save

Worksheet (Class) is returned by the workbook object-related method

Write (Rows,colx,cell_value,style): Edit cell
Row (ROWX). Write (Colx,cell_value,style): Edit line
Flush_row_data (): Reduces memory pressure and can no longer be modified before flush
Col (Colx), write (Rows,cell_value,style): Edit column

EASYXF (function) Create Xfstyle instance, format control

Expression Syntax: (<element>:(<attribute> <value>,) +;) +
<element>-<attribute >-<value>:
(Bold is the default format, not all listed below)
Font      -bold          -True or   False
         -colour        -{colour}
&nbs P        -Italic        -True or  False
    &NB Sp    -name          -name of the font,  Arial
    &N Bsp    -underline    -True or  False

Alignment-direction    -  General , LR, RL
         -Hor Izontal   &NBSP;-&NBSP, General , left, center, right, filled 
        & nbsp -Vertical      -  Bottom , top, center, justified, distributed
    & nbsp    -shrink_to_fit-true or  False

Bolders  -left           -An integer width between 0 and
    &NBS P        -right         -an integer width between 0 and
           -top           -an integer width between 0 and
  & nbsp        -bottom        -An integer width between 0 and
           -diag           -An integer width between 0 and
    & nbsp      -left_colour  -{colour}*,  automatic colour
      & nbsp   -right_colour  - {colour}*,  automatic colour
          -...

Pattern-back_color-{colour}*, automatic colour
-Fore_colour-{colour}*, automatic colour
-Pattern- None, solid, fine_dots, sparse_dots

{colous}*: Black, (Dark_) (Light_) Blue, gold, (Dark_) (light_) green, ivory, lavender,

(Light_) Orange, Pink, (Dark_) red, rose, violet, White, (Dark_) (light_) Yellow, ...

Xlutils

Copy: Will xlrd. Book converted to Xlwt.workbook
Styles: Read xlrd. The style of each cell in the workbook
Display: Simple and safe rendering of data read by XLRD
Filter: Splitting and consolidating multiple XLS files
Margins: View table sparsity level
Save: Serializes the xlrd. Book, dump as binary XLS or stream

Python operations Excel

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.