问题标签 [phpword]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
7 回答
16860 浏览

php - PhpWord 不替换文本

我有一个 docx 文件,我需要替换一些文本。这是在 codeigniter 框架内完成的;这是代码:

当我打开新文件时,我仍然得到“replacename”而不是“new”。"replacename" 格式为 Verdana 字体,9pt 字体大小(无下划线或粗体)。为什么它不起作用?从 setValue 函数(和 doc 文件)中删除 ${ } 它可以工作

0 投票
2 回答
2074 浏览

listitem - 如何使用 addListItem() 在 PHPWord 上重新开始编号?

我正在创建一个文档,该文档将在页面上包含多个编号列表,并创建了两个列表定义,如下所示:

然后在循环中调用它们以添加到列表中:

但是,第二个列表编号从 11 开始 - 我怎样才能将它设置回 1?

0 投票
3 回答
8433 浏览

php - 如何更改 PHPWord 上的样式表?

我在使用插件 phpword 时遇到问题。我正在尝试更改样式,但我可以更改单元格的背景,并且它会考虑其他参数。

如果你想看我的代码,他在这里: http: //pastebin.com/pw36n3aW

0 投票
2 回答
2491 浏览

php - 使用 PHPWord 识别 HTML 标签

有没有办法让 PHPWord 重新调整 HTML 标签。我不需要更复杂的一次,只需<strong>and <em>。如果没有我可以使用的函数或库,那么任何关于如何加粗<strong>和斜体<em>标签的想法都会很高兴听到。

0 投票
1 回答
8839 浏览

php - PHPWord在一行上加粗某些单词

我想知道是否有办法在一行上加粗某些单词。例如,如果我想在一行粗体上每隔三个单词,我会怎么做。我目前正在使用 addText 但这需要整行加粗或不加粗。任何回应将不胜感激。

0 投票
9 回答
36196 浏览

php - PHPWord how to add text break / new line while in a text run

How can I add a text break or go to the next line/row while in a text run? I tried to just do $section->addTextBreak(2); while in the text run but it just added the breaks to the section after the text run. I also tried $textrun->addTextBreak(2); but it gave me a fatal error. Any responses would be greatly appreciated.

0 投票
2 回答
5093 浏览

openxml - 为什么 Office OpenXML 在标签之间拆分文本以及如何防止它?

我目前正在尝试使用PHPWord库及其模板系统处理 docx 文件。我已经找到并更新了一些人(不记得名字,但它并不重要)到这个库的路径,该库可以与表一起使用(复制它的行,然后在每一行上使用 PHPWord 中的标准 setValue())。

如果我创建自己的文档,xml 中的数据是正常结构,所以要替换的变量 ${variable} 在它自己的标签中,如下所示:

我简化了代码,在实际代码中还有许多其他标签描述大小、样式等。

我的问题是我必须处理来自其他人的文件,在这些文件中我被禁止进行重大更改,我得到一个文件,在某些时候他们是一个有一个空白行的表格。我添加了 ${variable} 变量并通过 PHPWord 运行它。问题是,它失败了。经过一番研究,我发现源 XML 如下所示:

(再次大大简化,但你明白了)

这种结构对我来说是个问题,因为克隆行的函数使用 strpos()、substr() 和正则表达式来工作,并且不适用于这种结构(我无法想象这样做的优雅方式)。

所以问题是 - 有人知道为什么 docx 会这样做以及如何阻止他吗?我正在寻找通过 word 的解决方案,而不是 PHP(我需要当前功能无需太多编辑即可工作)

0 投票
3 回答
13405 浏览

php - 使用 PHPWord 格式化表格单元格中的文本,例如粗体、字体、大小等

我有下面的代码片段

如何将文本格式添加到单元格值以粗体、斜体、字体大小等,我已尝试如上所示,但它不起作用

0 投票
2 回答
3431 浏览

php - Want to generate a docx file and send it as attachment using PHP (PHPMailer)

I have created a Patient Medical Report form, the work is I want to generate a proper formatted and compatible docx file (mostly consist table and paragraph) with value received by the filled form and send it as attachment without saving anywhere.

To create docx file I want to use PHPWord plugin and I also tried HTMLtoDOCX for docx generation but I want to send the dynamically generated docx file in attachment. (Don't tell me to use PHPDocx because I have its community version and its generating either blank file or file with less text than added)

I am using PHPMailer to send Emails. I don't want to attach file use AddAttachment Function because it is use for permanent file that is located somewhere.

Currently I am able to send a dynamically generated doc file using PHPMailer but the file is not compatible with MS Word 2010 the code for generating doc file and send it as attachment is:

If I comment out the line-4 and line-5 for docx then I didn't receive the HTML msg and also the file is also changed to a different unsupported word file.

The conclusion of this complete question is that I need the properly formatted Docx file according the design I want or the template I have and send it as attachment without any save or download dialog box.

If I use these headers then a dialog box come out with open and save option (I don't want this also)

I hope you all understand what I want. If somebody will give me right direction or solution then 1000000000000000 thanks in advance because I have wasted 2 days on this issue only.

0 投票
1 回答
1576 浏览

php - 使用phpword下载附件word文件

我的问题是我希望能够将文本区域内容下载为word文件-如果我停止保存到服务器代码(内容与文本区域中所写的内容完全相同),该代码就可以工作-但是当我添加下载代码时下载的文件将包含编程的页面格式,请帮助我

使用的代码是:

更新: 我发现问题只是因为我没有 Office 2007 抱歉,但即使我没有办公室,文件也以 word 文件打开,所以我认为这不会是问题制造者 :( 抱歉困扰你

但是在打开文件之前仍然存在问题我收到警告消息“说内容已损坏,如果我不能从源头确保我不应该打开它!” 行与行之间也没有中断(好像我在一个段落中写了所有单词!