最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2020年02月17日 09:58:46   作者:paeser  
在本篇文章里小編給大家整理的是關(guān)于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í)行程序,第一遍可以,第二遍就不行了!

其實, 關(guān)于 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()

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

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

相關(guān)文章

最新評論

孝感市| 宜黄县| 崇文区| 新沂市| 临桂县| 绵竹市| 上思县| 新邵县| 安庆市| 丹棱县| 历史| 筠连县| 新闻| 泸州市| 酒泉市| 沧州市| 伊金霍洛旗| 张家口市| 石家庄市| 奈曼旗| 丘北县| 台州市| 岑巩县| 太康县| 内乡县| 兰溪市| 楚雄市| 通州区| 遂川县| 泸西县| 朝阳县| 延津县| 临洮县| 新化县| 普格县| 彝良县| 宕昌县| 天祝| 多伦县| 兴和县| 阿拉善盟|