GeneXus学习笔记-Excel导出
生活随笔
收集整理的這篇文章主要介紹了
GeneXus学习笔记-Excel导出
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
Excel導(dǎo)出是在一個Procedure中實現(xiàn)的。
就是一個方法。傳入的參數(shù)可以是你的頁面篩選條件。傳出的可以是一些比如文件名之類的。
參數(shù)
傳入傳出參數(shù)是在rules中定義:
Parm(in:&inParm1,in:&inParm2,in:&inParm3,out:&Filename,out:&ErrorMessage);
參數(shù)可以自己定
具體實現(xiàn)
下面把標(biāo)藍(lán)的地方改成需要的就可以直接用
do 'InitParm'
do 'WriteTitles'
do 'WriteCells'Sub 'WriteCells'For eachwhere Attribute1 = &Variable1 when not &Variable1.IsEmpty() //添加篩選條件,就是rules里傳過來的where Attribute2 = &Variable2 when not &Variable2.IsEmpty()where Attribute3 = &Variable3 when not &Variable3.IsEmpty()// Write cell valuesif &CellRow >= 65535 //Excel2003版本的一個sheet最多支持65535行數(shù)據(jù),當(dāng)行數(shù)超過65535行時,需要新建一個sheet&Sheeti += 1&ExcelDocument.SelectSheet('Sheet'+&Sheeti.ToString().Trim())//新建sheet,并切換到新sheet上Do 'WriteTitles'endif &CellRow += 1&CellCursor = 0&ExcelDocument.Cells(&CellRow, &FirstColumn + &CellCursor).Text = Attribute1&CellCursor += 1&ExcelDocument.Cells(&CellRow, &FirstColumn + &CellCursor).Text = Attribute2&CellCursor += 1&ExcelDocument.Cells(&CellRow, &FirstColumn + &CellCursor).Text = Attribute3&CellCursor += 1&ExcelDocument.Cells(&CellRow, &FirstColumn + &CellCursor).Text = Attribute4&CellCursor += 1&ExcelDocument.Cells(&CellRow, &FirstColumn + &CellCursor).Text = Attribute5&CellCursor += 1Endfor&ExcelDocument.Save() Do 'CheckStatus'&ExcelDocument.Close()
EndSubSub 'WriteTitles' //寫titles// Write titles&CellCursor = 0&CellRow = 1&FirstColumn = 1&ExcelDocument.Cells(&CellRow, &FirstColumn + &CellCursor).Bold = True&ExcelDocument.Cells(&CellRow, &FirstColumn + &CellCursor).Text = 'title1'&CellCursor += 1&ExcelDocument.Cells(&CellRow, &FirstColumn + &CellCursor).Bold = True&ExcelDocument.Cells(&CellRow, &FirstColumn + &CellCursor).Text = 'title2'&CellCursor += 1&ExcelDocument.Cells(&CellRow, &FirstColumn + &CellCursor).Bold = True&ExcelDocument.Cells(&CellRow, &FirstColumn + &CellCursor).Text = 'title3'&CellCursor += 1&ExcelDocument.Cells(&CellRow, &FirstColumn + &CellCursor).Bold = True&ExcelDocument.Cells(&CellRow, &FirstColumn + &CellCursor).Text = 'title4'&CellCursor += 1&ExcelDocument.Cells(&CellRow, &FirstColumn + &CellCursor).Bold = True&ExcelDocument.Cells(&CellRow, &FirstColumn + &CellCursor).Text = 'title5'&CellCursor += 1
EndSubSub 'InitParm'&Random = Random() * 10000&Filename =&Today.Year().ToString().Trim()+&Today.Month().ToString().Trim()+&Today.Day().ToString().Trim()+"_文件名_"+ &Random.ToString().Trim()//&ExcelTypeCode = P_GetSysParm('SysExcelType') //這里是獲取Excel 是.xls 還是.xlsx的。自己設(shè)置也行 from鄭俊//if &ExcelTypeCode = ''&ExcelTypeCode = '.xls'//endif&Filename += &ExcelTypeCode&Filename = "Excel\Export\" + &Filename&ExcelDocument.Open(&Filename)Do 'CheckStatus'&ExcelDocument.Clear()&Sheeti = 1
EndSubSub 'CheckStatus'If (&ExcelDocument.ErrCode <> 0)&Filename = ""&ErrorMessage = &ExcelDocument.ErrDescription&ExcelDocument.Close()ReturnEndif
Endsub //from 呂曉萌
總結(jié)
以上是生活随笔為你收集整理的GeneXus学习笔记-Excel导出的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 区块链开发者观点:《Learn EOS》
- 下一篇: css中字体下划线样式,css下划线 浅