怎样根据现有excel文件模板添加sheet表。。。急!!!

collinsyang 2003-12-15 03:57:50
现在有若干个excel文件模板,想组合成一个新excel文件,每个sheet为一个模板。请问有什么好方法实现。
...全文
91 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
lovedogdog 2003-12-16
  • 打赏
  • 举报
回复
Function CopySheet(vSheetFrom,vSheetTo)
on error resume next

dim i,irows
dim blExist

blExist = false
if vSheetFrom<>"" then
for i=1 to m_Sheets.Count '判断是否存在以vSheetFrom为名字的sheet
if m_Sheets(i).Name = vSheetFrom then
blExist= true
exit for
end if
next
end if

if not blExist then '利用原始模板sheet
vSheetFrom=m_Sheets(1).name
irows=m_StartRow
else
irows=m_DirTotal.Item(vSheetFrom)
end if

blExist = false
for i=1 to m_Sheets.Count '判断是否存在以vSheetTo为名字的sheet
if m_Sheets(i).Name = vSheetTo then
blExist= true
exit for
end if
next

if not blExist then '利用原始模板sheet
m_Sheets(vSheetFrom).copy ,m_Sheets(m_Sheets.Count) '.copy [befor],[after]
m_Sheets(m_Sheets.Count).Name = vSheetTo
m_DirTotal.Add vSheetTo,irows
set m_ExcelSheet = m_Sheets(vSheetTo)
m_ActiveSheetName = vSheetTo
else
m_ErrNo = 15
m_ErrDes = "the sheet " & vSheetTo & " already exist!"
end if

if Err.number<>0 then
m_ErrNo = Err.Number
m_ErrDes = Err.Description
end if
if m_ErrNo<>0 then
response.Redirect "message.asp?ErrNo=" & m_ErrNo & "&ErrDes=clsFillExcel::CopySheet<br>" & m_ErrDes
end if
End Function
collinsyang 2003-12-16
  • 打赏
  • 举报
回复
继续顶~~~~~~
collinsyang 2003-12-16
  • 打赏
  • 举报
回复
关于sheets的add方法有四个参数,可以都省略,但我需要根据现有模板文件添加sheet,不知道怎么写,请各位大虾指点


ActiveWorkBook.sheets.add(Before, After, Count, Type)
collinsyang 2003-12-16
  • 打赏
  • 举报
回复
请具体说一下,谢谢了
ABitTrouble 2003-12-15
  • 打赏
  • 举报
回复
Set myws = docFile.Worksheets("sheet1")
myws .add
具体修改各种属性,请看excel宏代码
collinsyang 2003-12-15
  • 打赏
  • 举报
回复
没人会吗?

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧