diff --git "a/\346\226\207\344\273\266/\350\257\273\345\217\226\346\225\260\346\215\256.xlsx" "b/\346\226\207\344\273\266/\350\257\273\345\217\226\346\225\260\346\215\256.xlsx" new file mode 100644 index 0000000000000000000000000000000000000000..d809e2fce3c5c0b262b3e5745166b00c58a74e45 Binary files /dev/null and "b/\346\226\207\344\273\266/\350\257\273\345\217\226\346\225\260\346\215\256.xlsx" differ diff --git "a/\350\207\252\345\212\250\345\214\226\345\212\236\345\205\254/\345\255\227\346\257\215\345\222\214\346\225\260\345\255\227\347\232\204\350\275\254\346\215\242.py" "b/\350\207\252\345\212\250\345\214\226\345\212\236\345\205\254/\345\255\227\346\257\215\345\222\214\346\225\260\345\255\227\347\232\204\350\275\254\346\215\242.py" new file mode 100644 index 0000000000000000000000000000000000000000..ad4862260eed8e917d746cf72e04b5c9bdfab244 --- /dev/null +++ "b/\350\207\252\345\212\250\345\214\226\345\212\236\345\205\254/\345\255\227\346\257\215\345\222\214\346\225\260\345\255\227\347\232\204\350\275\254\346\215\242.py" @@ -0,0 +1,7 @@ +import openpyxl as vb + +数字转字母 = vb.utils.get_column_letter(2) +print(数字转字母) + +字母转数字 = vb.utils.column_index_from_string('D') +print(字母转数字) diff --git "a/\350\207\252\345\212\250\345\214\226\345\212\236\345\205\254/\350\216\267\345\217\226\350\241\250\346\240\274\345\206\205\346\225\260\346\215\256.py" "b/\350\207\252\345\212\250\345\214\226\345\212\236\345\205\254/\350\216\267\345\217\226\350\241\250\346\240\274\345\206\205\346\225\260\346\215\256.py" new file mode 100644 index 0000000000000000000000000000000000000000..86ae5836d9e63abdfcf15af2eda83499cfa6fa0b --- /dev/null +++ "b/\350\207\252\345\212\250\345\214\226\345\212\236\345\205\254/\350\216\267\345\217\226\350\241\250\346\240\274\345\206\205\346\225\260\346\215\256.py" @@ -0,0 +1,24 @@ +import openpyxl as vb + +path = '../文件/读取数据.xlsx' +wb = vb.load_workbook(path) +wt = wb["Sheet1"] +""" +获取一个区域内的数据 +""" +cellArea = wt["A1:C10"] +for cellRow in cellArea: + for cell in cellRow: + print(cell.value) + +""" +使用List +""" +print(list(wt.values)) + +""" +使用iter_rows或者iter_column +""" +for row in wt.iter_rows(min_row=1, max_row=10, min_col=1, max_col=3): + for cell in row: + print(cell.value) diff --git "a/\350\207\252\345\212\250\345\214\226\345\212\236\345\205\254/\350\241\214\345\210\227\347\232\204\345\210\240\351\231\244\344\270\216\346\217\222\345\205\245.py" "b/\350\207\252\345\212\250\345\214\226\345\212\236\345\205\254/\350\241\214\345\210\227\347\232\204\345\210\240\351\231\244\344\270\216\346\217\222\345\205\245.py" new file mode 100644 index 0000000000000000000000000000000000000000..40e15cbb0097bbabc4cb8f4268be8fb8f17b5519 --- /dev/null +++ "b/\350\207\252\345\212\250\345\214\226\345\212\236\345\205\254/\350\241\214\345\210\227\347\232\204\345\210\240\351\231\244\344\270\216\346\217\222\345\205\245.py" @@ -0,0 +1,13 @@ +import openpyxl as vb + +path = '../文件/读取数据.xlsx' +wb = vb.load_workbook(path) +wt = wb['Sheet1'] + +# wt.insert_cols(idx=2, amount=5) #插入列 +wt.insert_rows(idx=2, amount=5) # 插入行 + +wt.delete_rows(idx=2, amount=5) # 删除行 +wt.delete_cols(idx=2, amount=5) # 删除列 + +wb.save(path)