
如何用python创建excel表格
1个回答
展开全部
以下代码调试通过:
import
xlrd#
打开
xls
文件book
=
xlrd.open_workbook("test.xls")print
"表单数量:",
book.nsheetsprint
"表单名称:",
book.sheet_names()#
获取第1个表单sh
=
book.sheet_by_index(0)print
u"表单
%s
共
%d
行
%d
列"
%
(sh.name,
sh.nrows,
sh.ncols)print
"第二行第三列:",
sh.cell_value(1,
2)运行效果:
import
xlrd#
打开
xls
文件book
=
xlrd.open_workbook("test.xls")print
"表单数量:",
book.nsheetsprint
"表单名称:",
book.sheet_names()#
获取第1个表单sh
=
book.sheet_by_index(0)print
u"表单
%s
共
%d
行
%d
列"
%
(sh.name,
sh.nrows,
sh.ncols)print
"第二行第三列:",
sh.cell_value(1,
2)运行效果:
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询