예제 #1
0
def test3():
    myExcel = ABKExcel()  #create a object
    myExcel.open(r'C:\Users\hp\Desktop\ABKTt.xls')  #open a Excel File
    sheet_name_list = myExcel.get_sheet_names()

    for name in sheet_name_list:
        myExcel.ReadOn()
        myExcel.readsheets(name)
        sheet = myExcel.getSheetByName(name)
        Tables = sheet.getTables()
예제 #2
0
def test2():
    table_col = 9
    table_row = 9
    col_span = 2
    row_span = 2

    table = ABKTable(row_span, col_span, table_row, table_col)
    table.initStyleOn()
    table.table_index = row_span

    table.absout_col = col_span

    table.setTitle('Multiple')

    table.setColor(2, 2, 'rose')  #设置颜色

    table.setMerge(3, 5, 9, 9)  #设置合并格

    #现在有一个问题就是这个数字变成字符串就ok。。。

    fontstyle = ['Batang', 1, 'blue', 880]
    table.setFont(8, 8, fontstyle)  #设置字体

    for irow in xrange(1, table_row + 1):
        for icol in xrange(1, table_col + 1):
            value = irow * icol
            table.setCellData(irow, icol, value)

    myExcel = ABKExcel()  #create a object

    myExcel.open(r'C:\Users\hp\Desktop\ABKTt.xls')  #open a Excel File

    name = 'Sheet1'

    myExcel.ReadOn()

    myExcel.readsheets(name)

    sheet = myExcel.getSheetByName(name)

    sheet.insertTable(table, 0)

    myExcel.WriteOn()  # 是否允许对这个文件的修改

    # 如果名字重了,就提示是否保存...
    myExcel.save()

    myExcel.close()