asp動態生成excel檔案

2021-08-21 23:27:35 字數 1803 閱讀 6401

<%

'##################實現將動態生成excel**,並將內容一併寫入######################

'#######################code createby guofeng#####################################

%>

生成在交費記錄的excel

<%

if request("act") = "" then

else

'######################主程式開始###################

'###############code createby guofeng###############

dim sql,filename,fs,myfile,x,link

set fs = server.createobject("scripting.filesystemobject")

'--假設你想讓生成的excel檔案做如下的存放

filename = "e:/龍山紀念林客戶管理/online.xls"

'--如果原來的excel檔案存在的話刪除它

if fs.fileexists(filename) then

fs.deletefile(filename)

end if

'--建立excel檔案

set myfile = fs.createtextfile(filename,true)

set rs = server.createobject("adodb.recordset")

'--從資料庫中把你想放到excel中的資料查出來

'sql = "select population,hourpos,datepos from populationperhour order by datepos,hourpos asc"

sql="select * from basic order by id"

rs.open sql,conn

if rs.eof and rs.bof then

else

'######################開始寫入###################

'###############code createby guofeng###############

dim strline,responsestr

strline=""

for each x in rs.fields

strline= strline & x.name & chr(9)

next

'--將表的列名先寫入excel

myfile.writeline strline

do while not rs.eof

strline=""

for each x in rs.fields

strline= strline & x.value & chr(9)

next

'--將表的資料寫入excel

myfile.writeline strline

rs.movenext

loop

end if

rs.close

set rs = nothing

conn.close

set conn = nothing

set myfile = nothing

set fs=nothing

link="open the excel file"

response.write link

end if

%>

動態生成excel

20gp的合併運費,補錄費用,箱號 iteratorit list.iterator 20gp箱子數量 int twetygp 0 臨時箱號 string tempcontainerno 臨時運費 bigdecimal yf new bigdecimal 0 需要刪除箱子的臨時id string t...

Excel動態生成JSON

在最近的乙個專案中,有大量的資料來源來至excel,轉成json供前台使用。excel資料是人工錄入的,難免會有錯誤,所以中間會有邏輯檢查。在c 中 讀取excel 的方式有很多,網上一搜一大堆,這裡我也貼出乙個excelhelper,提供根據excel檔案獲取所有sheet名稱和獲取sheet內容...

用asp生成PDF檔案

首先必須在定義欄位的工作站 不是伺服器 上安裝有adobe完全版。這個是乙個指向adobe forms acrobat toolkit的鏈結,由此開始一切就容易了。http partners.adobe.asn developer acrosdk forms.html 並把它解壓縮到指定目錄。當你進...