PowerBuilder中调用NPOI进行Excel导出格式设置示例

2023-09-11,,

//    功能        :新建excel带边框的单元格,格式为数字并显示为美元货币
// 参数 :ai_row,行号;ai_col,列号
// 返回值 :true/false
// 作者 :潮崖之飔
// 日期 :--
// 修改记录: #IF DEFINED PBDOTNET THEN
NPOI.SS.UserModel.IRow row
row =io_sheet.GetRow(ai_row)
IF isnull(row) THEN
row=io_sheet.CreateRow(ai_row)
END IF NPOI.SS.UserModel.ICell cell
cell = row.GetCell(ai_col)
IF isnull(cell) THEN
cell=row.CreateCell(ai_col)
END IF if isnull (io_cellstyle) then io_cellstyle=io_workbook.CreateCellstyle()
if isnull (i_dollarformat) then i_dollarformat=io_workbook.CreateDataFormat(); io_cellstyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.THIN
io_cellstyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.THIN
io_cellstyle.BorderRight = NPOI.SS.UserModel.BorderStyle.THIN
io_cellstyle.BorderTop = NPOI.SS.UserModel.BorderStyle.THIN
//io_cellstyle.WrapText = True //自动换行
//io_cellstyle.SetCellValue(row(col1).ToString().Replace("|", Environment.NewLine))//将某个字符替换为回车换行
io_cellstyle.DataFormat = i_dollarformat.GetFormat("~"$~"#,##0_);[red](~"$~"#,##0)")
cell.cellstyle =io_cellstyle
#END IF
RETURN true

PowerBuilder中调用NPOI进行Excel导出格式设置示例的相关教程结束。

《PowerBuilder中调用NPOI进行Excel导出格式设置示例.doc》

下载本文的Word格式文档,以方便收藏与打印。