NPOI 1.2.3教程 -6 重复Repeat
来源:互联网 发布:备份数据库管家婆 编辑:程序博客网 时间:2024/05/20 04:49
using System;
using System.Text;
using System.IO;
using NPOI.HSSF.UserModel;
using NPOI.HPSF;
using NPOI.POIFS.FileSystem;
using NPOI.SS.UserModel;
namespace RepeatingRowsAndColumns
{
class Program
{
static void Main(string[] args)
{
InitializeWorkbook();
Sheet sheet1 = hssfworkbook.CreateSheet("first sheet");
hssfworkbook.CreateSheet("second sheet");
hssfworkbook.CreateSheet("third sheet");
Font boldFont = hssfworkbook.CreateFont();
boldFont.FontHeightInPoints = 22;
boldFont.Boldweight = (short)FontBoldWeight.BOLD;
CellStyle boldStyle = hssfworkbook.CreateCellStyle();
boldStyle.SetFont(boldFont);
Row row = sheet1.CreateRow(1);
Cell cell = row.CreateCell(0);
cell.SetCellValue("This quick brown fox");
cell.CellStyle = (boldStyle);
// Set the columns to repeat from column 0 to 2 on the first sheet
hssfworkbook.SetRepeatingRowsAndColumns(0, 0, 2, -1, -1);
// Set the rows to repeat from row 0 to 2 on the second sheet.
hssfworkbook.SetRepeatingRowsAndColumns(1, -1, -1, 0, 2);
// Set the the repeating rows and columns on the third sheet.
hssfworkbook.SetRepeatingRowsAndColumns(2, 4, 5, 1, 2);
WriteToFile();
}
static HSSFWorkbook hssfworkbook;
static void WriteToFile()
{
//Write the stream data of workbook to the root directory
FileStream file = new FileStream(@"test.xls", FileMode.Create);
hssfworkbook.Write(file);
file.Close();
}
static void InitializeWorkbook()
{
hssfworkbook = new HSSFWorkbook();
//Create a entry of DocumentSummaryInformation
DocumentSummaryInformation dsi = PropertySetFactory.CreateDocumentSummaryInformation();
dsi.Company = "NPOI Team";
hssfworkbook.DocumentSummaryInformation = dsi;
//Create a entry of SummaryInformation
SummaryInformation si = PropertySetFactory.CreateSummaryInformation();
si.Subject = "NPOI SDK Example";
hssfworkbook.SummaryInformation = si;
}
}
}
- NPOI 1.2.3教程 -6 重复Repeat
- NPOI 1.2.3教程 - 1 认识NPOI
- NPOI 1.2.3教程 - 2 使用NPOI生成xls文件
- NPOI 1.2.3教程 -5 分拆凍結 SplitAndFreeze
- NPOI 1.2.3教程 -8 打印Print
- NPOI 1.2.3教程 -9 格式化Format
- NPOI 1.2.3教程 -10批注Comment
- NPOI 1.2.3教程 -12 对齐Alignment
- NPOI 1.2.3教程 -18 分组Group
- NPOI 1.2.3教程 -21 下载Download
- NPOI 1.2.3教程 -22 画图Drawing
- NPOI 1.2.3教程 -26 字体Font
- NPOI 1.2.3教程 -27 超级链接Hyperlink
- NPOI 1.2教程
- NPOI 1.2教程(目录)
- NPOI 1.2教程(目录)
- NPOI 1.2教程(目录)
- NPOI 1.2.3教程 - 3 縮放Zoom
- NPOI 1.2.3教程 - 4 基本公式 BasicFormula
- 反向代理
- 速度、屏幕和内容 - 三星移动亮相CES 2011
- I386 X86
- NPOI 1.2.3教程 -5 分拆凍結 SplitAndFreeze
- NPOI 1.2.3教程 -6 重复Repeat
- linux编程的108种奇淫巧计-15(减少复制)
- 如何用intent调用android系统程序打开指定图片
- 《程序员》精彩推荐:如何为新员工找到团队“归属感”
- 三星通信研究院bada应用软件开发者挑战赛
- 1-18
- 关于C语言变量和函数命名规范
- 突然发现个事
- 对提交给mysql语句内容进行防错处理