下面展示一些 内联代码片
。
生成PDF文件
private static void nopipdf()
{
ISheet sheet;
IRow row;
ICell cell;
using (FileStream fs = new FileStream(@"C:\Users\魏凯\Desktop\测试文档.xlsx", FileMode.Open, FileAccess.Read))
{
IWorkbook workbook = WorkbookFactory.Create(fs);
sheet = workbook.GetSheetAt(0);
// 读取 Excel 文件中的数据
for (int i = 0; i <= sheet.LastRowNum; i++)
{
row = sheet.GetRow(i);
if (row != null)
{
for (int j = 0; j < row.LastCellNum; j++)
{
cell = row.GetCell(j);
if (cell != null)
{
// 读取单元格中的数据
Console.Write(cell.ToString() + " ");
}
}
Console.WriteLine();
}
}
}
using (FileStream fs = new FileStream(@"C:\Users\魏凯\Desktop\测试文档.pdf", FileMode.Create, FileAccess.Write))
{
BaseFont bfHei = BaseFont.CreateFont(@"c:/windows/fonts/SIMHEI.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
Document doc = new Document()