用于高级文档处理的SDK 与微软Office格式高度兼容 立即下载 这是什么? 强大的文本、电子表格、演示文稿和PDF生成工具。 ONLYOFFICE文档生成器是支持您的应用软件修改或创建DOCX、XLSX、PPTX或PDF格式文档的工具,且无需运行Microsoft Office。在线演示 双许可证模式 ONLYOFFICE文档生成器附带双许可证模式。这意味着只要您遵循GNU AGPL v.3许可证,就可以使用GitHub上提供的ONLYOFFICE开源解决方案。为了保护您的知识产权和获取专业支持,您必须拥有Commercial License。联系销售 ONLYOFFICE文档生成器有哪些特点? 通过ONLYOFFICE文本生成器,您可以为每一个文档创建简单脚本,无论是新文件还是您需要打开并修改的旧文件。您再也无需像使用其他生成器一样,在每次更改时都编译应用程序。开始动态生成您的文档!阅读文档 ONLYOFFICE文档生成器功能 ONLYOFFICE文档生成器支持所有常见的文档格式,可打开DOC、DOCX、ODT、RTF、TXT、XLS、XLSX、ODS、CSV、PPT、PPSX、PPS、ODP和PPTX,并保存为DOCX、ODT、XLSX、PPTX或PDF。 高级文档处理 创建电子表格,生成报告 易于创建演示文稿 创建可填写的表单 快速生成 PDF 文件 高级文档处理 插入文本、段落、图像、表格和图表、自选图形、页眉和页脚,创建带项目符号或编号的列表等。使用数据库中的信息填充表格。 builder.CreateFile("docx"); var oDocument = Api.GetDocument(); var oParagraph, oRun, oDrawing, oTextPr; oParagraph = oDocument.GetElement(0); oDrawing = Api.CreateImage("https://www.onlyoffice.com/images/landing/document-builder/document.jpg", 1556 * 3600, 1044 * 3600); oParagraph.AddDrawing(oDrawing); oTextPr = oDocument.GetDefaultTextPr(); oTextPr.SetFontSize(24); oTextPr.SetColor(64,64,64); oParagraph = Api.CreateParagraph(); oRun = Api.CreateRun(); oRun.SetFontSize(36); oRun.SetColor(0,112,192); oRun.SetBold(true); oRun.AddText("Advanced document processing,"); oDocument.Push(oParagraph); oParagraph = Api.CreateParagraph(); oRun = Api.CreateRun(); oRun.SetFontSize(24); oRun.SetColor(0,176,240); oRun.SetBold(true); oRun.AddText("Insert formatted text"); oParagraph.AddElement(oRun); oRun = Api.CreateRun(); oRun.AddText(", paragraphs, "); oParagraph.AddElement(oRun); oRun = Api.CreateRun(); oRun.SetFontSize(24); oRun.SetColor(8,140,68); oRun.SetBold(true); oRun.SetUnderline(true); oRun.AddText("images"); oParagraph.AddElement(oRun); oRun = Api.CreateRun(); oRun.AddText(", tables and "); oParagraph.AddElement(oRun); oRun = Api.CreateRun(); oRun.SetFontSize(24); oRun.SetColor(255,106,0); oRun.SetBold(true); oRun.SetItalic(true); oRun.AddText("charts, "); oParagraph.AddElement(oRun); oRun = Api.CreateRun(); oRun.SetHighlight(255,255,0); oRun.AddText("shapes"); oParagraph.AddElement(oRun); oRun = Api.CreateRun(); oRun.AddText(", "); oParagraph.AddElement(oRun); oRun = Api.CreateRun(); oRun.SetItalic(true); oRun.SetVertAlign("superscript"); oRun.SetFontSize(40); oRun.AddText("headers"); oParagraph.AddElement(oRun); oRun = Api.CreateRun(); oRun.AddText(", and "); oParagraph.AddElement(oRun); oRun = Api.CreateRun(); oRun.SetItalic(true); oRun.SetVertAlign("subscript"); oRun.SetFontSize(40); oRun.AddText("footers"); oParagraph.AddElement(oRun); oRun = Api.CreateRun(); oRun.AddText(", create a bulleted or numbered list, etc. Populate a table using data from a database."); oParagraph.AddElement(oRun); oDocument.Push(oParagraph); oParagraph = Api.CreateParagraph(); oDocument.Push(oParagraph); oParagraph = Api.CreateParagraph(); oRun = Api.CreateRun(); oRun.SetFontSize(18); oRun.AddText("Best regards,"); oRun.AddLineBreak(); oRun.AddText("ONLYOFFICE Document Builder Team"); oParagraph.AddElement(oRun); oDocument.Push(oParagraph); for(var i=0; i<6; i++) { oParagraph = Api.CreateParagraph(); oDocument.Push(oParagraph); } oParagraph = Api.CreateParagraph(); var oFill = Api.CreateSolidFill(Api.CreateRGBColor(217,217,217)); var oStroke = Api.CreateStroke(0, Api.CreateNoFill()); oDrawing = Api.CreateShape("rect", 1568 * 3600, 9000, oFill, oStroke); oParagraph.AddDrawing(oDrawing); oDocument.Push(oParagraph); oParagraph = Api.CreateParagraph(); oDocument.Push(oParagraph); oParagraph = Api.CreateParagraph(); oFill = Api.CreateSolidFill(Api.CreateRGBColor(230,156,164)); oStroke = Api.CreateStroke(0, Api.CreateNoFill()); oDrawing = Api.CreateShape("heart", 69 * 3600, 58 * 3600, oFill, oStroke); oDrawing.SetWrappingStyle("square"); oDrawing.SetVerAlign("paragraph", "center"); oParagraph.AddDrawing(oDrawing); oRun = Api.CreateRun(); oRun.SetFontSize(22); oRun.AddText(" Have a question? Contact sales at "); oParagraph.AddElement(oRun); oRun = Api.CreateRun(); oRun.SetFontSize(22); oRun.SetColor(107,159,37); oRun.SetUnderline(true); oRun.AddText("sales@onlyoffice.com"); oParagraph.AddElement(oRun); oDocument.Push(oParagraph); builder.SaveFile("docx", "sampletext.docx"); builder.CloseFile(); 结果文档 文本文档 API,用于 .NET PHP Java Node.js Ruby Python 编辑 转换 合并 拆分 压缩 对比 旋转 删除页面 生成报告 创建发票 翻译 删除评论 查找和替换 解析器 邮件合并 OCR 水印 注释 创建电子表格,生成报告 将选定的单元格区域格式化为表格。插入图片、各种类型的图表和自选图形。生成报告,管理和分析数据。 builder.CreateFile("xlsx"); var oParagraph, oRun; var cellLabels = ["Net Profit", "PayPal Fee", "Shipping", "Tax", "Cost"]; var cellValues = [50252, 6218, 22093, 8214, 60618]; var oSheet = Api.GetActiveSheet(); oSheet.SetName("Spreadsheet"); oSheet.SetColumnWidth(0, 28); oSheet.SetColumnWidth(1, 22); oSheet.SetColumnWidth(2, 20); oSheet.SetColumnWidth(3, 11); oSheet.SetRowHeight(0, 42); for(var i=1; i<13; i++){ oSheet.SetRowHeight(i, 28); } oSheet.GetRange("A1:C1").Merge(true); oSheet.GetRange("A1:C15").SetFontName("Arial"); var sRange = oSheet.GetRange("A1"); sRange.SetFontColor(Api.CreateColorFromRGB(12,153,112)); sRange.SetFontSize(18); sRange.SetBold(true); sRange.SetValue("Spreadsheet creation and reporting"); oSheet.GetRange("A2:L2").Merge(true); sRange = oSheet.GetRange("A2"); sRange.SetFontSize(12); sRange.SetValue("Format the selected range of cells as a table. Insert images, different types of charts and various shapes. Generate reports to organize and analyze your data."); var sRange = oSheet.GetRange("A6"); sRange.SetFontColor(Api.CreateColorFromRGB(0,112,192)); sRange.SetFontSize(15); sRange.SetBold(true); sRange.SetValue(" Sales Report"); oSheet.GetRange("A5:D15").SetBorders("InsideHorizontal", "Thin", Api.CreateColorFromRGB(255,255,255)); oSheet.GetRange("A5:D15").SetBorders("InsideVertical", "Thin", Api.CreateColorFromRGB(255,255,255)); oSheet.GetRange("B8:B13").SetNumberFormat("$#,##0.00"); oSheet.GetRange("B8:B13").SetFontColor( Api.CreateColorFromRGB(12,153,112)); oSheet.GetRange("B8:B13").SetBold(true); for(var i=0; i<cellLabels.length; i++){ oCellNumber = i + 8; oSheet.GetRange("A" + oCellNumber.toString()).SetValue(" " + cellLabels[i]); oSheet.GetRange("B" + oCellNumber.toString()).SetValue(cellValues[i]); } oSheet.GetRange("B13").SetValue("=SUM(B8:B12)"); oSheet.GetRange("C8:C13").SetNumberFormat("0.00%"); oSheet.GetRange("C8:C13").SetFontColor( Api.CreateColorFromRGB(0,117,162)); oSheet.GetRange("C8:C13").SetBold(true); for(var i=0; i<cellLabels.length; i++){ oCellNumber = i + 8; oSheet.GetRange("C" + oCellNumber.toString()).SetValue("=B" + oCellNumber.toString() +"/B13"); } oSheet.GetRange("C13").SetValue("=SUM(C8:C12)"); oSheet.GetRange("B7").SetFontColor( Api.CreateColorFromRGB(128,128,128)); oSheet.GetRange("B7").SetAlignHorizontal("right"); oSheet.GetRange("B7").SetValue("$ USD"); oSheet.GetRange("C7").SetFontColor( Api.CreateColorFromRGB(128,128,128)); oSheet.GetRange("C7").SetAlignHorizontal("right"); oSheet.GetRange("C7").SetValue("% Percent"); oSheet.GetRange("A13").SetFontSize(14); oSheet.GetRange("A13").SetValue(" Total Sales"); oSheet.GetRange("B13").SetFontSize(14); oSheet.GetRange("C13").SetFontSize(14); var oChart = oSheet.AddChart("Spreadsheet!$B$8:$B$12", false, "bar", 2, 1254 * 3600, 987 * 3600, 4, 0, 4, 0); oChart.SetShowDataLabels(false, false, false); oChart.SetTitle("$ USD", 16); var oChart = oSheet.AddChart("Spreadsheet!$C$8:$C$12", false, "doughnut", 2, 1273 * 3600, 987 * 3600, 11, 7 * 36000, 4, 0); oChart.SetShowDataLabels(false, false, false); oChart.SetTitle("% Percent", 16); var oFill = Api.CreateSolidFill(Api.CreateRGBColor(255,255,255)); var oStroke = Api.CreateStroke(0, Api.CreateNoFill()); var oDrawing = oSheet.AddShape("rect", 1550 * 3600, 207 * 3600, oFill, oStroke, 0, 0, 18, 5 * 3600); var oDocContent = oDrawing.GetDocContent(); var oFill1 = Api.CreateSolidFill(Api.CreateRGBColor(12,155,116)); var oStroke1 = Api.CreateStroke(0, Api.CreateNoFill()); var oDrawing1 = oSheet.AddShape("heart", 69 * 3600, 58 * 3600, oFill1, oStroke1, 0, 3 * 36000, 19, 1 * 36000); oDocContent.RemoveAllElements(); oParagraph = Api.CreateParagraph(); oRun = Api.CreateRun(); oRun.SetBold(true); oRun.SetFontSize(28); oRun.SetFill(Api.CreateSolidFill(Api.CreateRGBColor(0,0,0))); oRun.AddText(" Have a question?"); oParagraph.AddElement(oRun); oRun = Api.CreateRun(); oRun.SetFontSize(28); oRun.SetFill(Api.CreateSolidFill(Api.CreateRGBColor(0,0,0))); oRun.AddText(" Contact sales at "); oParagraph.AddElement(oRun); oRun = Api.CreateRun(); oRun.SetFontSize(28); oRun.SetFill(Api.CreateSolidFill(Api.CreateRGBColor(244,145,0))); oRun.SetUnderline(true); oRun.AddText("sales@onlyoffice.com"); oParagraph.AddElement(oRun); oDocContent.Push(oParagraph); builder.SaveFile("xlsx", "samplespreadsheet.xlsx"); builder.CloseFile(); 结果文档 电子表格 API,用于 .NET PHP Java Node.js Ruby Python 编辑 转换 XLSX 转 PDF XLSX 转 PNG XLSX 转 HTML XLSX 转 CSV 合并 拆分 压缩 构建内容 查找和替换 渲染图表 清除内容 颠倒和旋转行与列 解析器 易于创建演示文稿 添加和管理幻灯片,设置背景。创建自选图形、图表,插入图片。在自选图形和段落中设置文本格式。使用渐变、纯色或图案填充选项。 builder.CreateFile("pptx"); var oPresentation = Api.GetPresentation(); var oSlide = oPresentation.GetSlideByIndex(0); if(!oSlide){ oSlide = Api.CreateSlide(); oPresentation.AddSlide(oSlide); } oPresentation.SetSizes(12192000, 6858000); var oFill = Api.CreateBlipFill("https://www.onlyoffice.com/images/landing/document-builder/presentation1.jpg", "stretch"); oSlide.SetBackground(oFill); oSlide.RemoveAllObjects(); var oShape = Api.CreateShape('rect', 1920*3600, 850*3600, Api.CreateNoFill(), Api.CreateStroke(0, Api.CreateNoFill())); oShape.SetPosition(1183470, 1647320); var oContent = oShape.GetDocContent(); var oParagraph = oContent.GetElement(0); oParagraph.SetSpacingBefore(0, undefined); oParagraph.SetSpacingAfter(0, undefined); oParagraph.SetSpacingLine(9 * 24, "auto"); var oRun = oParagraph.AddText('Smooth presentation creation'); oRun.SetFill(Api.CreateSolidFill(Api.CreateRGBColor(255,230,201))); oRun.SetFontSize(144); oRun.SetFontFamily('Arial'); oRun.SetBold(true); oSlide.AddObject(oShape); oSlide = Api.CreateSlide(); oPresentation.AddSlide(oSlide); oFill = Api.CreateBlipFill("https://www.onlyoffice.com/images/landing/document-builder/presentation2.jpg", "stretch"); oSlide.SetBackground(oFill); oSlide.RemoveAllObjects(); oShape = Api.CreateShape('rect', 881*3600, 360*3600, Api.CreateNoFill(), Api.CreateStroke(0, Api.CreateNoFill())); oShape.SetPosition(723232, 4744282); oContent = oShape.GetDocContent(); oParagraph = oContent.GetElement(0); oParagraph.SetSpacingBefore(0, undefined); oParagraph.SetSpacingAfter(0, undefined); oParagraph.SetSpacingLine(9 * 24, "auto"); oRun = oParagraph.AddText('Add and manage slides, set their background.'); oRun.SetFill(Api.CreateSolidFill(Api.CreateRGBColor(255,255,255))); oRun.SetFontSize(44); oRun.SetFontFamily('Arial'); oSlide.AddObject(oShape); oShape = Api.CreateShape('rect', 928*3600, 389*3600, Api.CreateNoFill(), Api.CreateStroke(0, Api.CreateNoFill())); oShape.SetPosition(4460660, 4744282); oContent = oShape.GetDocContent(); oParagraph = oContent.GetElement(0); oParagraph.SetSpacingBefore(0, undefined); oParagraph.SetSpacingAfter(0, undefined); oParagraph.SetSpacingLine(9 * 24, "auto"); oRun = oParagraph.AddText('Create shapes, charts, insert images. Format text in shapes and paragraphs.'); oRun.SetFill(Api.CreateSolidFill(Api.CreateRGBColor(255,255,255))); oRun.SetFontSize(44); oRun.SetFontFamily('Arial'); oSlide.AddObject(oShape); oShape = Api.CreateShape('rect', 810*3600, 417*3600, Api.CreateNoFill(), Api.CreateStroke(0, Api.CreateNoFill())); oShape.SetPosition(8432224, 4744282); oContent = oShape.GetDocContent(); oParagraph = oContent.GetElement(0); oParagraph.SetSpacingBefore(0, undefined); oParagraph.SetSpacingAfter(0, undefined); oParagraph.SetSpacingLine(9 * 24, "auto"); oRun = oParagraph.AddText('Use the Gradient, Solid or Pattern Fill option.'); oRun.SetFill(Api.CreateSolidFill(Api.CreateRGBColor(255,255,255))); oRun.SetFontSize(44); oRun.SetFontFamily('Arial'); oSlide.AddObject(oShape); oGs1 = Api.CreateGradientStop(Api.CreateRGBColor(255,219,178), 0); oGs2 = Api.CreateGradientStop(Api.CreateRGBColor(240,173,173), 100000); oFill = Api.CreateLinearGradientFill([oGs1, oGs2], 13500000); oShape = Api.CreateShape('rect', 374*3600, 221*3600, oFill, Api.CreateStroke(0, Api.CreateNoFill())); oShape.SetPosition(1901130, 2765280); oSlide.AddObject(oShape); oGs1 = Api.CreateGradientStop(Api.CreateRGBColor(161,232,255), 0); oGs2 = Api.CreateGradientStop(Api.CreateRGBColor(135,209,232), 100000); oFill = Api.CreateLinearGradientFill([oGs1, oGs2], 13500000); oShape = Api.CreateShape('rect', 374*3600, 221*3600, oFill, Api.CreateStroke(0, Api.CreateNoFill())); oShape.SetPosition(1464940, 2411390); oSlide.AddObject(oShape); oGs1 = Api.CreateGradientStop(Api.CreateRGBColor(57,151,219), 0); oGs2 = Api.CreateGradientStop(Api.CreateRGBColor(0,112,192), 100000); oFill = Api.CreateLinearGradientFill([oGs1, oGs2], 13500000); oShape = Api.CreateShape('rect', 374*3600, 221*3600, oFill, Api.CreateStroke(0, Api.CreateNoFill())); oShape.SetPosition(995830, 2016350); oSlide.AddObject(oShape); oFill = Api.CreateSolidFill(Api.CreateRGBColor(255,255,204)); oShape = Api.CreateShape('mathPlus', 95*3600, 95*3600, oFill, Api.CreateStroke(0, Api.CreateNoFill())); oShape.SetPosition(1497860, 2246790); oSlide.AddObject(oShape); oFill = Api.CreateSolidFill(Api.CreateRGBColor(255,255,204)); oShape = Api.CreateShape('rect', 240*3600, 467*3600, oFill, Api.CreateStroke(0, Api.CreateNoFill())); oShape.SetPosition(6337100, 1901130); oSlide.AddObject(oShape); oFill = Api.CreateSolidFill(Api.CreateRGBColor(255,181,181)); oShape = Api.CreateShape('rect', 231*3600, 366*3600, oFill, Api.CreateStroke(0, Api.CreateNoFill())); oShape.SetPosition(5802150, 2263250); oSlide.AddObject(oShape); oFill = Api.CreateSolidFill(Api.CreateRGBColor(161,232,255)); oShape = Api.CreateShape('rect', 251*3600, 250*3600, oFill, Api.CreateStroke(0, Api.CreateNoFill())); oShape.SetPosition(5275430, 2682980); oSlide.AddObject(oShape); oFill = Api.CreateSolidFill(Api.CreateRGBColor(0,112,192)); oShape = Api.CreateShape('rect', 177*3600, 144*3600, oFill, Api.CreateStroke(0, Api.CreateNoFill())); oShape.SetPosition(4929770, 3061560); oSlide.AddObject(oShape); oGs1 = Api.CreateGradientStop(Api.CreateRGBColor(242,242,172), 0); oGs2 = Api.CreateGradientStop(Api.CreateRGBColor(240,173,173), 100000); oFill = Api.CreateLinearGradientFill([oGs1, oGs2], 0); oShape = Api.CreateShape('blockArc', 706*3600, 706*3600, oFill, Api.CreateStroke(0, Api.CreateNoFill())); oShape.SetPosition(8583890, 2362010); oSlide.AddObject(oShape); oGs1 = Api.CreateGradientStop(Api.CreateRGBColor(0,112,192), 0); oGs2 = Api.CreateGradientStop(Api.CreateRGBColor(135,209,232), 100000); oFill = Api.CreateLinearGradientFill([oGs1, oGs2], 0); oShape = Api.CreateShape('blockArc', 530*3600, 530*3600, oFill, Api.CreateStroke(0, Api.CreateNoFill())); oShape.SetPosition(8913090, 2680000); oSlide.AddObject(oShape); builder.SaveFile("pptx", "samplepresentation.pptx"); builder.CloseFile(); 结果文档 演示文稿 API,用于 .NET PHP Java Node.js Ruby Python 编辑 转换 搜索 合并 拆分 查找和替换 创建图表 合并图片 解析器 创建可填写的表单 添加不同的字段进行填写,包括文本字段、图片、组合框、下拉列表和复选框。 builder.CreateFile("docx"); var oDocument = Api.GetDocument(); var oParagraph = oDocument.GetElement(0); var oTextForm = Api.CreateTextForm({"key": "Text form", "tip": "Enter your text here", "required": true, "placeholder": "Text form", "comb": true, "maxCharacters": 56, "cellWidth": 5, "multiLine": false, "autoFit": false}); oParagraph.AddElement(oTextForm); var oTextPr = oTextForm.GetTextPr(); oTextPr.SetFontSize(24); oTextPr.SetBold(true); oTextForm.SetBorderColor(255, 0, 0); oTextForm.SetText("Create a text form and change its properties as you want"); oDocument.Push(oParagraph); oParagraph = Api.CreateParagraph(); oParagraph.AddText("Create checkboxes to select multiple options: "); var oCheckBoxForm1 = Api.CreateCheckBoxForm({"tip": "You can select multiple options", "required": true, "radio": false}); var oCheckBoxForm2 = oCheckBoxForm1.Copy(); var oCheckBoxForm3 = oCheckBoxForm1.Copy(); oParagraph.AddElement(oCheckBoxForm1); oParagraph.AddElement(oCheckBoxForm2); oParagraph.AddElement(oCheckBoxForm3); oCheckBoxForm1.SetChecked(true); oCheckBoxForm3.SetChecked(true); oDocument.Push(oParagraph); oParagraph = Api.CreateParagraph(); oParagraph.AddText("Create radio buttons to select only one option in the radio button group: "); var oRadioButtonForm1 = Api.CreateCheckBoxForm({"tip": "You can select only one option", "required": true, "radio": true}); oRadioButtonForm1.SetRadioGroup("Radio buttons"); var oRadioButtonForm2 = oRadioButtonForm1.Copy(); var oRadioButtonForm3 = oRadioButtonForm1.Copy(); oParagraph.AddElement(oRadioButtonForm1); oParagraph.AddElement(oRadioButtonForm2); oParagraph.AddElement(oRadioButtonForm3); oRadioButtonForm1.SetChecked(true); oDocument.Push(oParagraph); oParagraph = Api.CreateParagraph(); oParagraph.AddText("Create a combo box to select the specified item from the combo box list: "); var oComboBoxForm = Api.CreateComboBoxForm({"key": "Combo box form", "tip": "Choose an item", "required": true, "editable": true, "autoFit": false}); oParagraph.AddElement(oComboBoxForm); oComboBoxForm.SetListValues(["Item 1", "Item 2", "Item 3"]); oComboBoxForm.SelectListValue("Item 1"); oComboBoxForm.SetBackgroundColor(255, 255, 0); oDocument.Push(oParagraph); builder.SaveFile("pdf", "sampleform.pdf"); builder.CloseFile(); 结果文档 快速生成 PDF 文件 轻松将文档、电子表格和演示文稿另存为 PDF 格式。 builder.OpenFile("sampletext.docx", ""); var oDocument = Api.GetDocument(); var oParagraph = oDocument.GetElement(2); oParagraph.AddText(" Save the resulting document in the pdf format."); builder.SaveFile("pdf", "sampleformats.pdf"); builder.CloseFile(); 结果文档 合并 旋转 拆分 签名 ONLYOFFICE文档生成器背后的技术 ONLYOFFICE文档生成器提供一个JavaScript API,具有完善的文档记录,并且易于使用。从我们的库中选择适当的方法和类,或者选择常用的JavaScript方法更改某些元素格式设置属性。阅读文档 无论您使用何种语言编写应用程序,文档生成器都可以与其相集成。.Net (C# MVC) .Net (C#) Node.js PHP Ruby立即下载 转换到企业层面 需要在自己的品牌下为终端用户带来先进的处理文档机会?选择文档生成器作为ONLYOFFICE Docs开发者版的一部分。 立即购买 有疑问? 通过sales@onlyoffice.com联系销售。 联系