本篇文章為大家展示了python中寫入excel的方法有哪些,內(nèi)容簡明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過這篇文章的詳細(xì)介紹希望你能有所收獲。

首先使用openpyxl進(jìn)行寫入操作,代碼如下:
book = openpyxl.Workbook()
auths = Auth.objects.filter(owner_id=1)
filename = '導(dǎo)出數(shù)據(jù)'
for auth in auths:
sheet = book.create_sheet(auth.name, index = 0)
sheet.append([
_("書名"),
_("作者"),
_("譯者"),
_("出版社"),
_("序列號(hào)"),
_("總頁數(shù)"),
])
objs = None
objs = Book.objects.filter(owner_id=auth.id)
for u in objs:
data = []
data.append(u.name)
data.append(auth.name)
data.append(u.translator)
data.append(u.press)
data.append(u.serializer)
data.append(u.page)
sheet.append(data)
return ExcelBookResponse(book, filename)
文章名稱:python中寫入excel的方法有哪些-創(chuàng)新互聯(lián)
轉(zhuǎn)載注明:http://www.yijiale78.com/article16/cspsgg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供建站公司、品牌網(wǎng)站制作、網(wǎng)站建設(shè)、軟件開發(fā)、微信公眾號(hào)、App開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容