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

ASP+模板生成Word、Excel、html的代碼

 更新時間:2008年06月18日 20:43:28   作者:  
由于工作的需要,我需要為客戶做一個在線生成Excel及Word報(bào)表程序,參考了網(wǎng)上很多辦法

生成Excel文檔:
復(fù)制代碼 代碼如下:

<% 
'創(chuàng)建文件 
dim templateName,templatechar,filepath,filename,fileCharset,templateContent 
   templateName="template/template_excel.htm"        '模板名字,支持帶路徑,如"/moban/moban1.htm"或"temp/moban1.htm" 
   templatechar="gb2312"                      '模板文本的編碼 
   filepath="files/excel/"                     '生成文件保存的路徑,當(dāng)前目錄請留空,其他目錄,路徑必須以“/”結(jié)尾 
   filename="Book1.xls"                           '即將生成的文件名 
   CreateMultiFolder(filepath)                '這一句用來判斷文件夾是否存在,沒有則自動創(chuàng)建,支持n級目錄 
   fileCharset="gb2312"                       '打算生成的文本編碼 
'讀取指定的模板內(nèi)容 
templateContent=ReadFromTextFile(templateName,templatechar)    
'以下就交給你來替換模板內(nèi)容了 
templateContent=replace(templateContent,"{$websiteName}","藍(lán)色理想") 
templateContent=replace(templateContent,"{$userName}","幸福的子彈") 
templateContent=replace(templateContent,"{$now}",Now()) 
'其他內(nèi)容...... 
'最終調(diào)用函數(shù)來生成文件          
Call WriteToTextFile(filepath&filename,templateContent,fileCharset)    
'最后關(guān)閉adodb.stream對象 
stm.flush 
stm.Close 
set stm=nothing 
downloadFile(filepath&filename) 
%> 

生成.htm靜態(tài)頁面
復(fù)制代碼 代碼如下:

<% 
'創(chuàng)建文件 
dim templateName,templatechar,filepath,filename,fileCharset,templateContent 
   templateName="template/template_html.htm"        '模板名字,支持帶路徑,如"/moban/moban1.htm"或"temp/moban1.htm" 
   templatechar="gb2312"                      '模板文本的編碼 
   filepath="files/html/"                     '生成文件保存的路徑,當(dāng)前目錄請留空,其他目錄,路徑必須以“/”結(jié)尾 
   filename="Untitled-1.htm"                           '即將生成的文件名 
   CreateMultiFolder(filepath)                '這一句用來判斷文件夾是否存在,沒有則自動創(chuàng)建,支持n級目錄 
   fileCharset="gb2312"                       '打算生成的文本編碼 
'讀取指定的模板內(nèi)容 
templateContent=ReadFromTextFile(templateName,templatechar)    
'以下就交給你來替換模板內(nèi)容了 
templateContent=replace(templateContent,"{$websiteName}","藍(lán)色理想") 
templateContent=replace(templateContent,"{$userName}","幸福的子彈") 
templateContent=replace(templateContent,"{$now}",now()) 
'其他內(nèi)容...... 
'最終調(diào)用函數(shù)來生成文件          
Call WriteToTextFile(filepath&filename,templateContent,fileCharset)    
'最后關(guān)閉adodb.stream對象 
stm.flush 
stm.Close 
set stm=nothing 
response.Write("恭喜您,"&filename&"已經(jīng)生成,<a href="""&filepath&filename&""" target=""_blank"">點(diǎn)擊查看</a>") 
%>

打包文件下載

相關(guān)文章

最新評論

连江县| 龙泉市| 张家界市| 海口市| 大田县| 墨竹工卡县| 伊宁县| 临邑县| 乌苏市| 兖州市| 手机| 饶河县| 河北区| 扎赉特旗| 龙岩市| 工布江达县| 蕉岭县| 黄石市| 阿克| 阿荣旗| 临武县| 林州市| 南开区| 广德县| 华坪县| 治县。| 塘沽区| 保德县| 喜德县| 盐边县| 顺平县| 宁强县| 裕民县| 镇雄县| 赤峰市| 连平县| 唐海县| 万山特区| 河东区| 鸡东县| 固安县|