| 028-81705109 | | 微信扫一扫 | |
作为e-iceblue 的客户,你可能想知道“它可以做什么”或者“怎么使用它”,为了回答大部分这种问题可以浏览每个产品页包含的功能描述或者参考相关的教程。下面列出的是一些你在使用中可能经常遇到的问题的答案。
如果你没有发现你问题的答案,请联系ag凯发旗舰厅(),并提供我们下面的详细信息。
document document = new document(); document.loadfromfile(@"..\..\test.docx"); using (streamwriter sw = file.createtext("output.txt")) { sw.write(document.gettext()); }
document document = new document(); document.loadfromfile("sample.docx", fileformat.docx); image image = image.fromfile("image.jpg"); //指定段落 paragraph paragraph = document.sections[0].paragraphs[2]; docpicture picture = paragraph.appendpicture(image); //调整图片大小 picture.height = picture.height * 0.8f; picture.width = picture.width * 0.8f; document.savetofile("result.docx", fileformat.docx);
document document = new document(); document.loadfromfile("sample.docx"); //左对齐 paragraph paragraph1 = document.sections[0].paragraphs[0]; paragraph1.format.horizontalalignment = horizontalalignment.left; //居中对齐 paragraph paragraph2 = document.sections[0].paragraphs[1]; paragraph2.format.horizontalalignment = horizontalalignment.center; //右对齐 paragraph paragraph3 = document.sections[0].paragraphs[2]; paragraph3.format.horizontalalignment = horizontalalignment.right; document.savetofile("result.docx");
document document = new document(); document.loadfromfile("sample.doc"); bookmarksnavigator bookmarknavigator = new bookmarksnavigator(document); bookmarknavigator.movetobookmark("mybookmark"); //替换书签中的内容 bookmarknavigator.replacebookmarkcontent("new context", false); document.savetofile("result.doc", fileformat.doc);
document document = new document(); document.loadfromfile("sample.doc"); //将word保存为html document.savetofile("result.html", fileformat.html); document.close();
document document = new document(); document.loadfromfile("sample.html", fileformat.html, xhtmlvalidationtype.none); //将html保存为word文档 document.savetofile("result.doc"); document.close();
document document = new document("word2007.docx"); //将word2007 转换为 word2003 document.savetofile("word2003.doc", fileformat.doc); document.close();
document document1 = new document(); document1.loadfromfile("merge1.docx"); document document2 = new document(); document2.loadfromfile("merge2.docx"); //把document2中的章节添加到document1 foreach (section sec in document2.sections) { document1.sections.add(sec.clone()); } document1.savetofile("result.docx");
document document = new document(); document.loadfromfile("sample.docx"); spire.doc.interface.itable table = document.sections[0].tables[0]; int i=0; //遍历单元格 foreach (tablerow row in table.rows) { foreach (tablecell cell in row.cells) { i ; } }
document document = new document(); section section = document.addsection(); paragraph paragraph = section.addparagraph(); textrange htext = paragraph.appendtext("this is a test!"); //设置isshadow属性 htext.characterformat.isshadow = true; htext.characterformat.fontsize = 80; document.savetofile("result.doc");
document document = new document(); section section = document.addsection(); //插入行号 section.pagesetup.linenumberingrestartmode = linenumberingrestartmode.restartpage; section.pagesetup.linenumberingstep = 1; section.pagesetup.linenumberingstartvalue = 1; paragraph paragraph = section.addparagraph(); paragraph.appendtext("as an independent word .net component, spire.doc for .net doesn't need microsoft word to be installed on the machine. however, it can incorporate microsoft word document creation capabilities into any developers .net applications."); document.savetofile("result.doc");
document document = new document(); section section = document.addsection(); paragraph paragraph = section.addparagraph(); string str = "as an independent word .net component, spire.doc for .net doesn't need microsoft word to be installed on the machine. however, it can incorporate microsoft word document creation capabilities into any developers.net applications.as an independent word .net component, spire.doc for .net doesn't need microsoft word to be installed on the machine. however, it can incorporate microsoft word document creation capabilities into any developers’.net applications."; paragraph.appendtext(str); docpicture picture = paragraph.appendpicture(image.fromfile("logo.png")); picture.textwrappingstyle = textwrappingstyle.tight; picture.horizontalalignment = shapehorizontalalignment.center; document.savetofile("result.doc");
document doc = new document("sample.docx"); section section = doc.sections[0]; itable table = section.tables[0]; //编辑单元格中的文本 tablecell cell1 = table.rows[1].cells[1]; paragraph p1 = cell1.paragraphs[0]; p1.text = "abc"; tablecell cell2 = table.rows[1].cells[2]; paragraph p2 = cell2.paragraphs[0]; p2.items.clear(); p2.appendtext("def"); tablecell cell3 = table.rows[1].cells[3]; paragraph p3 = cell3.paragraphs[0]; (p3.items[0] as textrange).text = "hij"; //插入新行 tablerow newrow = table.addrow(true, true); foreach (tablecell cell in newrow.cells) { cell.addparagraph().appendtext("new row"); } doc.savetofile("result.doc");
document document = new document(); section section = document.addsection(); paragraph paragraph = section.addparagraph(); field hyperlink = paragraph.appendhyperlink("www.e-iceblue.com", "www.e-iceblue.com", hyperlinktype.weblink); textrange text = hyperlink.nextsibling.nextsibling as textrange; text.characterformat.bold = true; text.characterformat.underlinestyle = underlinestyle.none; document.savetofile("result.doc");
document document = new document(); document.loadfromfile("sample.docx"); document.protect(protectiontype.allowonlyreading); document.savetofile("result.doc");
workbook workbook = new workbook(); worksheet sheet = workbook.worksheets[0]; sheet.pictures.add(3, 2, "day.jpg"); workbook.savetofile("result.xlsx");
workbook workbook = new workbook(); workbook.loadfromfile("sample.xlsx"); worksheet sheet = workbook.worksheets[0]; //在第三行插入新行 sheet.insertrow(3); workbook.savetofile("result.xlsx");
workbook workbook = new workbook(); workbook.loadfromfile("sample.xlsx"); worksheet sheet = workbook.worksheets[0]; //设置打印区域为b2到f8 sheet.pagesetup.printarea = "b2:f8"; workbook.savetofile("result.xlsx");
workbook workbook = new workbook(); workbook.loadfromfile("sample.xlsx"); worksheet sheet1 = workbook.worksheets[0]; worksheet sheet3 = workbook.worksheets[2]; //复制sheet1的单元格“b2”到sheet3的单元格“c6” sheet1.range[3, 2].copy(sheet3.range[6,3]); workbook.savetofile("result.xlsx");
workbook workbook = new workbook(); workbook.loadfromfile("sample.xlsx", excelversion.version2010); workbook.savetofile("result.pdf", spire.xls.fileformat.pdf);
workbook workbook = new workbook(); workbook.loadfromfile("sample.xlsx"); worksheet sheet = workbook.worksheets[0]; //合并"b3"到"b4"的单元格 sheet.range["b3:b4"].merge(); workbook.savetofile("result.xlsx");
workbook workbook = new workbook(); workbook.loadfromfile("sample.xlsx"); worksheet sheet = workbook.worksheets[3]; //将第4张工作表移到第1张工作表的位置 sheet.moveworksheet(0); workbook.savetofile("result.xlsx");
workbook workbook = new workbook(); workbook.loadfromfile("sample.xlsx"); worksheet sheet = workbook.worksheets[1]; //删除第2列 sheet.deletecolumn(2); //删除第4列 sheet.deletecolumn(3); workbook.savetofile("result.xlsx");
workbook workbook = new workbook(); workbook.loadfromfile("sample.xlsx"); worksheet sheet = workbook.worksheets[0]; //设置指定范围的数字格式 sheet.range[2, 2, 6, 6].numberformat = "$#,##0.00"; sheet.range["c3"].numbervalue = 3240.689; sheet.range["d4"].numbervalue = 5230.123; workbook.savetofile("result.xlsx");
workbook workbook = new workbook(); worksheet worksheet = workbook.worksheets[0]; //添加if公式到单元格j7中 string formula = @"=if(h7>0,(if(f7 > 0,(h7-f7)/f7,"""")),"""")"; worksheet.range["j7"].formula = formula; worksheet.range["f7"].numbervalue = 5; worksheet.range["h7"].numbervalue = 4; workbook.savetofile("result.xlsx", excelversion.version2007);
workbook workbook = new workbook(); workbook.loadfromfile("sample1.xlsx"); workbook workbookdest = new workbook(); workbookdest.loadfromfile("sample2.xlsx"); //将workbook中的单元格拷贝到workbookdest中 workbookdest.worksheets.addcopy(workbook.worksheets); workbookdest.savetofile("result.xlsx");
pdfdocument pdf = new pdfdocument(); pdfhtmllayoutformat htmllayoutformat = new pdfhtmllayoutformat(); htmllayoutformat.iswaiting = false; pdfpagesettings setting = new pdfpagesettings(); setting.size = pdfpagesize.a4; string htmlcode = file.readalltext("..\\..\\2.html"); thread thread = new thread(() => { pdf.loadfromhtml(htmlcode, false, setting, htmllayoutformat);}); thread.setapartmentstate(apartmentstate.sta); thread.start(); thread.join(); pdf.savetofile("output.pdf");
pdfdocument document = new pdfdocument(); pdfpagebase page = document.pages.add(pdfpagesize.a4); //新建一个网格 pdfgrid grid = new pdfgrid(); grid.columns.add(1); grid.columns[0].width = page.canvas.clientsize.width; pdfgridrow row0 = grid.rows.add(); row0.cells[0].value = "this is the first row."; row0.cells[0].stringformat = new pdfstringformat(pdftextalignment.center, pdfverticalalignment.middle); pdfgridrow row1 = grid.rows.add(); pdflayoutresult result=grid.draw(page, new pointf(0, 20)); pdfgrid grid2 = new pdfgrid(); grid2.columns.add(2); pdfgridrow newrow = grid2.rows.add(); grid2.columns[0].width = grid.columns[0].width / 2; grid2.columns[1].width = grid.columns[0].width / 2; newrow.cells[0].value = "this is row two column one."; newrow.cells[0].stringformat = new pdfstringformat(pdftextalignment.center, pdfverticalalignment.middle); newrow.cells[1].value = "this is row two column two."; newrow.cells[1].stringformat = new pdfstringformat(pdftextalignment.center, pdfverticalalignment.middle); //将grid2嵌入到grid的row1的第一个单元格中 row1.cells[0].value = grid2; result = grid2.draw(page, new pointf(0, result.bounds.location.y result.bounds.height)); document.savetofile("result.pdf");
pdfdocument doc = new pdfdocument(); pdfpagebase page = doc.pages.add(); pdfgrid grid = new pdfgrid(); grid.columns.add(5); float width = page.canvas.clientsize.width - (grid.columns.count 1); for (int i = 0; i < grid.columns.count; i ) { grid.columns[i].width = width * 0.20f; } pdfgridrow row0 = grid.rows.add(); pdfgridrow row1 = grid.rows.add(); row0.style.font = new pdftruetypefont(new font("arial", 16f, fontstyle.bold), true); row1.style.font = new pdftruetypefont(new font("arial", 16f, fontstyle.italic), true); row0.cells[0].value = "corporation"; //将row0的第一个单元格与下面的单元格合并 row0.cells[0].rowspan = 2; row0.cells[1].value = "b&k undersea photo"; row0.cells[1].stringformat = new pdfstringformat(pdftextalignment.center, pdfverticalalignment.middle); //将row0的第二个单元格与右边的单元格合并 row0.cells[1].columnspan = 3; row0.cells[4].value = "world"; row0.cells[4].style.font = new pdftruetypefont(new font("arial", 10f, fontstyle.bold | fontstyle.italic), true); row0.cells[4].stringformat = new pdfstringformat(pdftextalignment.center, pdfverticalalignment.middle); row0.cells[4].style.backgroundbrush = pdfbrushes.lightgreen; row1.cells[1].value = "diving international unlimited"; row1.cells[1].stringformat = new pdfstringformat(pdftextalignment.center, pdfverticalalignment.middle); row1.cells[1].columnspan = 4; grid.draw(page, new pointf(0, 0)); doc.savetofile("result.pdf");
pdfdocument doc = new pdfdocument(); doc.loadfromfile("sample.pdf"); pdfcertificate cert = new pdfcertificate("demo.pfx", "e-iceblue"); //给每一页都添加一个signature foreach (pdfpagebase page in doc.pages) { pdfsignature signature = new pdfsignature(page.document, page, cert, "demo"); signature.contactinfo = "harry"; signature.certificated = true; signature.documentpermissions = pdfcertificationflags.allowformfill; } doc.savetofile("result.pdf");
document document = new document(); document.loadfromfile("sample.doc"); //将word保存为html document.savetofile("result.html", fileformat.html); document.close();
pdfdocument document = new pdfdocument(); //sample.pdf has four pages document.loadfromfile("sample.pdf"); //重新调整页面顺序 int[] range = new int[] { 0, 2, 1, 3 }; document.pages.rearrange(range); document.savetofile("result.pdf");
pdfdocument pdf = new pdfdocument(); pdf.loadfromfile("sample.pdf"); pdfpagebase page = pdf.pages[0]; image img = image.fromfile("logo.png"); page.backgroundimage = img; page.backgroundregion = new rectanglef(300, 200, 80, 81); pdf.savetofile("result.pdf");
static void main(string[] args) { pdfdocument doc = new pdfdocument(); pdfunitconvertor unitcvtr = new pdfunitconvertor(); pdfmargins margin = new pdfmargins(); margin.top = unitcvtr.convertunits(3.0f, pdfgraphicsunit.centimeter, pdfgraphicsunit.point); margin.bottom = margin.top; margin.left = unitcvtr.convertunits(3.17f, pdfgraphicsunit.centimeter, pdfgraphicsunit.point); margin.right = margin.left; //添加3页 pdfpagebase page = doc.pages.add(pdfpagesize.a4, margin); page = doc.pages.add(pdfpagesize.a4, margin); page = doc.pages.add(pdfpagesize.a4, margin); //应用模板 setdocumenttemplate(doc, pdfpagesize.a4, margin); doc.savetofile("result.pdf"); } //method to add header to every page private static void setdocumenttemplate(pdfdocument doc, sizef pagesize, pdfmargins margin) { pdfpagetemplateelement leftspace = new pdfpagetemplateelement(margin.left, pagesize.height); doc.template.left = leftspace; pdfpagetemplateelement topspace = new pdfpagetemplateelement(pagesize.width, margin.top); topspace.foreground = true; doc.template.top = topspace; //draw header label pdftruetypefont font = new pdftruetypefont(new font("arial", 9f, fontstyle.italic)); pdfstringformat format = new pdfstringformat(pdftextalignment.right); string label = "demo about header repeating"; //set the header style sizef size = font.measurestring(label, format); float y = topspace.height - font.height - 40; pdfpen pen = new pdfpen(color.black, 0.75f); topspace.graphics.settransparency(0.5f); topspace.graphics.drawline(pen, margin.left - 30, y, pagesize.width - margin.right 30, y); y = y - 1 - size.height; topspace.graphics.drawstring(label, font, pdfbrushes.black, pagesize.width - margin.right, y, format); pdfpagetemplateelement rightspace = new pdfpagetemplateelement(margin.right, pagesize.height); doc.template.right = rightspace; pdfpagetemplateelement bottomspace = new pdfpagetemplateelement(pagesize.width, margin.bottom); bottomspace.foreground = true; doc.template.bottom = bottomspace; }
presentation presentation = new presentation(); presentation.loadfromfile("sample.pptx"); presentation.encrypt("test"); presentation.savetofile("encrypt.pptx", fileformat.pptx2010);
presentation presentation = new presentation(); //加载文件 presentation.loadfromfile("ppt.ppt"); //把文件保存成pdf presentation.savetofile("topdf.pdf", fileformat.pdf);
presentation ppt = new presentation(); ppt.loadfromfile(@"f:\testing\sample.pptx"); for (int i = 0; i < ppt.slides.count; i ) { //将幻灯片保存到image中 image image = ppt.slides[i].saveasimage(); string filename = string.format("5614-img-{0}.png", i); //将image保存成文件 image.save(filename, system.drawing.imaging.imageformat.png); }
presentation presentation = new presentation(); //添加一个shape iautoshape shape = presentation.slides[0].shapes.appendshape(shapetype.rectangle, new rectanglef(50, 70, 600, 400)); //设置shape里面第一段的对齐方式为左对齐 shape.textframe.paragraphs[0].alignment = textalignmenttype.left; shape.fill.filltype = fillformattype.none; //添加文本 shape.textframe.text = "demo about alignment"; presentation.savetofile("alignment.pptx", fileformat.pptx2010);
stringbuilder sb = new stringbuilder(); for (int i = 0; i < ppt.slides.count;i ) { for (int j = 0; j < ppt.slides[i].shapes.count;j ) { if (ppt.slides[i].shapes[j] is iautoshape) { iautoshape shape=ppt.slides[i].shapes[j] as iautoshape; if (shape.textframe != null) { foreach (textparagraph tp in shape.textframe.paragraphs) { sb.append(tp.text environment.newline); } } } } }
presentation ppt = new presentation(); iautoshape shape = (iautoshape)ppt.slides[0].shapes.appendshape(shapetype.doublewave, new rectanglef(100, 100, 400, 200)); string picurl = @"c:\users\administrator\desktop\image.jpg"; shape.fill.filltype = fillformattype.picture; shape.fill.picturefill.picture.url = picurl; shape.fill.picturefill.filltype = picturefilltype.stretch; shape.shapestyle.linecolor.color = color.transparent; ppt.savetofile("shape.pptx", fileformat.pptx2010);