NOPI使用手冊

2022-04-01 15:42:12 字數 2721 閱讀 5479

有些客戶匯出或者匯入時,對excel的格式要求很高,就需要用到nopi。**樣例:

imports

system

imports

system.web

imports

system.web.ui

imports

system.web.ui.webcontrols

imports

system.io

imports

npoi.hssf.usermodel

imports

npoi.hpsf

imports

npoi.poifs.filesystem

imports

npoi.ss.usermodel

partial

public

class

_default

inherits

system.web.ui.page

protected

sub page_load(byval sender as

object, byval e as

eventargs)

end sub

'點選按鈕後輸出檔案資料流

protected

sub button1_click(byval sender as

object, byval e as

eventargs)

dim filename as

string = "

test.xls

"response.contenttype = "

"response.addheader(

"content-disposition

", string.format("

attachment;filename=

", filename))

response.clear()

'呼叫初始化excel檔案

initializeworkbook()

'生成資料

generatedata()

'輸出excel檔案流

response.binarywrite(writetostream().getbuffer())

response.[

end]()

end sub

'定義workbook

private hssfworkbook as

hssfworkbook

'private

function writetostream() as

memorystream

'write the stream data of workbook to the root directory

dim file as

newmemorystream()

hssfworkbook.write(file)

return

file

end function

'生成資料

private

subgeneratedata()

'生成乙個sheet

dim sheet1 as isheet = hssfworkbook.createsheet("

sheet1")

'迴圈向sheet裡面新增資料

sheet1.createrow(0).createcell(0).setcellvalue("

this is a sample")

dim x as

integer = 1

for i as

integer = 1

to15

dim row as irow =sheet1.createrow(i)

for j as

integer = 0

to14

row.createcell(j).setcellvalue(system.math.max(system.threading.interlocked.increment(x), x - 1

))

next

next

end sub

'初始化乙個workbook(活動工作表)

private

subinitializeworkbook()

hssfworkbook = new

hssfworkbook()

'''/create a entry of documentsummaryinformation

dim dsi as documentsummaryinformation =propertysetfactory.createdocumentsummaryinformation()

dsi.company = "

npoi team

"hssfworkbook.documentsummaryinformation =dsi

'''/create a entry of summaryinformation

dim si as summaryinformation =propertysetfactory.createsummaryinformation()

si.subject = "

npoi sdk example

"hssfworkbook.summaryinformation =si

end sub

end class

CVS使用手冊

注意 第一次匯出以後,就不是通過cvs checkout來同步檔案了,而是要進入剛才cvs checkout project name匯出的project name目錄下進行具體檔案的版本同步 新增,修改,刪除 操作。cvs的許可權管理分2種策略 基於系統檔案許可權的系統使用者管理 適合多個在lin...

sed使用手冊

原貼 http blog.chinaunix.net u 23204 showart 305602.html sed使用手冊 原創 在sed語句,正規表示式必須封閉在 中間。如 d,刪除空行。sed位址 在sed位址管理中,預設是對全域性進行操作,同時位址可以分為行位址和模式位址。如1,10d 12...

vi 使用手冊

進入vi的命令 vi filename 開啟或新建檔案,並將游標置於第一行首 vi n filename 開啟檔案,並將游標置於第n行首 vi filename 開啟檔案,並將游標置於最後一行首 vi pattern filename 開啟檔案,並將游標置於第乙個與pattern匹配的串處 vi r...