亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Python 讀取有公式cell的結(jié)果內(nèi)容實例方法

 更新時間:2020年02月17日 09:58:46   作者:paeser  
在本篇文章里小編給大家整理的是關于Python 如何讀取有公式cell的結(jié)果內(nèi)容,需要的朋友們可以學習下。

操作Excel通常是用如下三個擴展體:

  1. import xlrd
  2. import xlwt
  3. import openpyxl

wb1 = openpyxl.load_workbook(xlsxFileWithFullPath, data_only=True)

就是加上 “data_only=True” 這個參數(shù)。

xlsxFileWithFullPath ---要操作的文件。

加上以后你會發(fā)現(xiàn),還是依然如故,或者是時可時否!

如把文件打開,再保存一遍,執(zhí)行程序,第一遍可以,第二遍就不行了!

其實, 關于 data_only=True 這個參數(shù)有個重要說明:

# data_only (bool) – controls whether cells with formula have either the formula (default) or the value stored the last time Excel read the sheet

這就解釋了上述時可時否的問題。

這樣解決問題的辦法就有了:用程序來完成那個保存文件的任務即可!

(1)

def ReadLine(self, tip1, tip2, movingRC, fixedRC, RorC, totalCells, sheetName, xlsxFileWithFullPath):

[!!]just open and save the file once! why? see bellow!
xlsxDealer.`JustOpenAndSaveTheFile`(xlsxFileWithFullPath)

(2)

def JustOpenAndSaveTheFile(self, file_name):
from win32com.client import Dispatch
xlApp = Dispatch("Excel.Application")
xlApp.Visible = False
xlBook = xlApp.Workbooks.Open(file_name)
xlBook.Save()
xlBook.Close()

問題是解決了,速度就是有點慢!

以上就是本次介紹的全部相關知識點,感謝大家的學習,歡迎轉(zhuǎn)載。

相關文章

最新評論