• <menu id="w2i4a"></menu>
  • logo Aspose中文文檔

    文檔首頁(yè)>>Aspose中文文檔>>在NPOI中創(chuàng)建表

    在NPOI中創(chuàng)建表


    Aspose.Words是一種高級(jí)Word文檔處理API,用于執(zhí)行各種文檔管理和操作任務(wù)。API支持生成,修改,轉(zhuǎn)換,呈現(xiàn)和打印文檔,而無(wú)需在跨平臺(tái)應(yīng)用程序中直接使用Microsoft Word。

    Aspose API支持流行文件格式處理,并允許將各類(lèi)文檔導(dǎo)出或轉(zhuǎn)換為固定布局文件格式和最常用的圖像/多媒體格式。

    Aspose.Words for .NET 最新下載

    Aspose.Words

    在Aspose.Words中,通常使用DocumentBuilder插入表格。以下方法用于建表。還將使用其他方法將內(nèi)容插入到表格單元格中。 DocumentBuilder.StartTable

    • DocumentBuilder.InsertCell
    • DocumentBuilder.EndRow
    • DocumentBuilder.EndTable
    • DocumentBuilder.Writeln
    using Aspose.Words;
    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);
    builder.ParagraphFormat.Borders.Top.LineStyle = LineStyle.Thick;
    builder.ParagraphFormat.Shading.BackgroundPatternColor = System.Drawing.ColorTranslator.FromHtml("#EEEEEE");
    builder.ParagraphFormat.Shading.Texture = TextureIndex.TextureDarkDiagonalUp;
    builder.Writeln("Title1");
    builder.ParagraphFormat.ClearFormatting();
    builder.InsertBreak(BreakType.ParagraphBreak);
    
    // We call this method to start building the table.
    builder.StartTable();
    builder.InsertCell();
    builder.CellFormat.Shading.BackgroundPatternColor = System.Drawing.ColorTranslator.FromHtml("#FF0000");
    builder.Font.Position = 100;
    builder.Font.Name = "Courier";
    builder.Font.Bold = true;
    builder.Font.Underline = Underline.DotDotDash;
    builder.Write("The quick brown fox");
    builder.InsertCell();
    builder.Font.ClearFormatting();
    builder.CellFormat.ClearFormatting();
    builder.InsertCell();
    builder.EndRow();
    builder.InsertCell();
    builder.InsertCell();
    builder.Write("EXAMPLE OF TABLE");
    builder.InsertCell();
    builder.EndRow();
    builder.InsertCell();
    builder.InsertCell();
    builder.InsertCell();
    builder.Write("only text");
    builder.EndRow();
    
    // Signal that we have finished building the table.
    builder.EndTable();
    doc.Save("simpleTable.docx");

    點(diǎn)擊復(fù)制

    NPOI

    using NPOI.XWPF.UserModel;
    XWPFDocument doc = new XWPFDocument();
    XWPFParagraph para= doc.CreateParagraph();
    XWPFRun r0 = para.CreateRun();
    r0.SetText("Title1");
    para.BorderTop = Borders.THICK;
    para.FillBackgroundColor = "EEEEEE";
    para.FillPattern = NPOI.OpenXmlFormats.Wordprocessing.ST_Shd.diagStripe;
    XWPFTable table = doc.CreateTable(3, 3);
    table.GetRow(1).GetCell(1).SetText("EXAMPLE OF TABLE");
    XWPFTableCell c1 = table.GetRow(0).GetCell(0);
    XWPFParagraph p1 = c1.AddParagraph(); //don't use doc.CreateParagraph
    XWPFRun r1 = p1.CreateRun();
    r1.SetText("The quick brown fox");
    r1.SetBold(true);
    r1.FontFamily = "Courier";
    r1.SetUnderline(UnderlinePatterns.DotDotDash);
    r1.SetTextPosition(100);
    c1.SetColor("FF0000");
    table.GetRow(2).GetCell(2).SetText("only text");
    FileStream out1 = new FileStream("simpleTable.docx", FileMode.Create);
    doc.Write(out1);
    out1.Close();

    點(diǎn)擊復(fù)制

    下載示例代碼

    掃碼咨詢(xún)


    添加微信 立即咨詢(xún)

    電話(huà)咨詢(xún)

    客服熱線(xiàn)
    023-68661681

    TOP
    三级成人熟女影院,欧美午夜成人精品视频,亚洲国产成人乱色在线观看,色中色成人论坛 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();