且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 python (openpyxl) 从 excel 中删除网格线

更新时间:2023-12-04 13:31:46

有一个相关的问题.另外,根据源代码 show_gridlines 只是一个完全没有影响的工作表类属性.只需观看问题即可获得任何更新.

There is a relevant issue in openpyxl issue tracker. Plus, according to the source code show_gridlines is just a worksheet class property that has no affect at all. Just watch the issue to get any update on it.

作为替代解决方案,请尝试新的、很棒的 xlsxwriter 模块.它能够隐藏工作表上的网格线(请参阅 docs).举个例子:

As an alternative solution, try the new and awesome xlsxwriter module. It has an ability to hide grid lines on a worksheet (see docs). Here's an example:

from xlsxwriter.workbook import Workbook

workbook = Workbook('hello_world.xlsx')
worksheet = workbook.add_worksheet()

worksheet.write('A1', 'Hello world')
worksheet.hide_gridlines(2)

workbook.close()