protected sub cmdorderexport_click(byval sender as object, byval e as eventargs) handles cmdorderexport.click
try
me.buildcondition()
dim ht as hashtable = apicurrent.api.dynamic.trade.searchgoodsstockinfo(objcondition)
'總件數
dim allcount as integer = ctype(ht.item(mco010.const_datacount), integer)
dim ds as datatable = ctype(ht.item(mco010.const_data), datatable)
' excel類
dim orderlistprinter as new goodsstocklistprint(me.getexceltemplatepath() & "goodsstocklist.xlt")
orderlistprinter.datasource = new object()
me.exportexcel(orderlistprinter)
catch ex as exception
logmanager.debug(ex.tostring)
me.controls.add(new literalcontrol(""))
end try
end sub
public class goodsstocklistprint
inherits excelcomm
'列數readonly col_cnt as integer = 18
'列的索引
private enum enum_col as integer
icol_stockid = 0 '編號
icol_goodsid = 1 '編號
icol_goodsname = 2 '名稱
icol_storeid = 3 '店鋪編號
icol_storename = 4 '店鋪
icol_companyid = 5 '編號
icol_companyname = 6 '經銷商
icol_specno1 = 7 '規格一編號
icol_specname1 = 8 '規格一
icol_specid1 = 9 '規格一明細編號
icol_specdtlname1 = 10 '規格明細一
icol_specno2 = 11 '規格二編號
icol_specname2 = 12 '規格二
icol_specid2 = 13 '規格二明細編號
icol_specdtlname2 = 14 '規格明細二
icol_initalstocknum = 15 '初始庫存
icol_remainingstocknum = 16 '剩餘庫存
icol_goodsprice = 17 '商品定價
end enum
'''
''' 建構函式
'''
'''
'''
public sub new(byval strtemppath as string)
mybase.new(strtemppath)
end sub
'''
''' 內容作成
'''
'''
'''
private sub exportdetail(byval arydata() as object)
dim objdata as datatable = arydata(0)
'定義陣列
dim strtemp(objdata.rows.count, col_cnt) as object
dim startrow as integer = 4
for i as integer = 0 to objdata.rows.count - 1
strtemp(i, enum_col.icol_stockid) = mco001.dbnull2str(objdata.rows(i).item("stockid")).trim
strtemp(i, enum_col.icol_goodsid) = mco001.dbnull2str(objdata.rows(i).item("goodsid")).trim
strtemp(i, enum_col.icol_goodsname) = mco001.dbnull2str(objdata.rows(i).item("goodsname")).trim
strtemp(i, enum_col.icol_storeid) = mco001.dbnull2str(objdata.rows(i).item("storeid")).trim
strtemp(i, enum_col.icol_storename) = mco001.dbnull2str(objdata.rows(i).item("storename")).trim
strtemp(i, enum_col.icol_companyid) = mco001.dbnull2str(objdata.rows(i).item("companyid")).trim
strtemp(i, enum_col.icol_companyname) = mco001.dbnull2str(objdata.rows(i).item("companyname")).trim
strtemp(i, enum_col.icol_specno1) = mco001.dbnull2str(objdata.rows(i).item("specno1")).trim
strtemp(i, enum_col.icol_specname1) = mco001.dbnull2str(objdata.rows(i).item("specname1")).trim
strtemp(i, enum_col.icol_specid1) = mco001.dbnull2str(objdata.rows(i).item("specid1")).trim
strtemp(i, enum_col.icol_specdtlname1) = mco001.dbnull2str(objdata.rows(i).item("specdtlname1")).trim
strtemp(i, enum_col.icol_specno2) = mco001.dbnull2str(objdata.rows(i).item("specno1")).trim
strtemp(i, enum_col.icol_specname2) = mco001.dbnull2str(objdata.rows(i).item("specname2")).trim
strtemp(i, enum_col.icol_specid2) = mco001.dbnull2str(objdata.rows(i).item("specid2")).trim
strtemp(i, enum_col.icol_specdtlname2) = mco001.dbnull2str(objdata.rows(i).item("specdtlname2")).trim
strtemp(i, enum_col.icol_initalstocknum) = mco001.dbnull2str(objdata.rows(i).item("initalstocknum")).trim
strtemp(i, enum_col.icol_remainingstocknum) = mco001.dbnull2str(objdata.rows(i).item("remainingstocknum")).trim
strtemp(i, enum_col.icol_goodsprice) = mco001.dbnull2str(objdata.rows(i).item("goodsprice")).trim
next
dim tmp as string = "a4:r" + (objdata.rows.count + 4).tostring
setrangevalue(me.sheet, strtemp, tmp, "")
'預設選中第一行
me.sheet.rows(1).select()
end sub
end class
匯出資料到Excel
最近做到了匯出資料這乙個功能,所以寫一下關於匯出資料的文獻,說一下自己是怎麼去做這乙個功能的。在我們要匯出資料之前,我們要查詢出我們要匯出的資訊,由於這裡是c 我就直接放圖了,下面是我自己資料庫中查詢的一些資訊 查詢出我們的資料後。我們要使用npoi來將我們的資訊寫入我們的文件中。npoi 是指構建...
匯出資料到Excel
使用npoi從資料庫中匯出資料到excel 新增npoi.dll程式集 下面 步驟解析 首先拿到要匯出的資料data,定義好excel模板 名稱 filename 可以放在本地 1 往excel模板中填充內容 writetofile data,filename filestream 物件讀取出來的是...
C 匯出Excel 匯出資料到Excel模板檔案裡
using excel microsoft.office.interop.excel using system.reflection missing 開啟模板檔案,得到workbook物件 workbook excel.workbooks.open templatepath,missing,miss...