是否有开发工具包/ lib(用c或c ++编写)来编写docx文件?微软有一个开发工具包,但它是用C#编写的.
我正在处理文档存储.因此我计划将SqlServer 2012与文件表一起使用.现在经过一些测试后,似乎SqlServer只索引doc而不是docx文件.
我还安装了Microsoft Filter Pack 2.0.
有人知道如何获得docx支持吗?也许还有一种获得pdf支持的方式?
非常感谢Boas
我有MS word doc保存为.docx.我想通过编辑docx的XML文件在我的文本中插入新行.我已经尝试过
, , ,	,AMD也总是给我唯一的空间不是一个新的生产线.
它能做什么:
(XML代码)
<w:t>hel
lo</w:t>
当我打开.docx文件然后它被更改为:
Hel lo不是因为我想成为Hel一条线和lo一条线.
我有一个docx文件,我想在编辑后返回.我有以下代码......
object useFile = Server.MapPath("~/Documents/File.docx");
object saveFile = Server.MapPath("~/Documents/savedFile.docx");
MemoryStream newDoc = repo.ChangeFile(useFile, saveFile);
return File(newDoc.GetBuffer().ToArray(), "application/docx", Server.UrlEncode("NewFile.docx"));
Run Code Online (Sandbox Code Playgroud)
该文件似乎很好,但我收到错误消息("文件已损坏"和另一个说"Word发现不可读的内容.如果您信任源点击是").有任何想法吗?
提前致谢
编辑
这是我模型中的ChangeFile ......
public MemoryStream ChangeFile(object useFile, object saveFile)
{
byte[] byteArray = File.ReadAllBytes(useFile.ToString());
using (MemoryStream ms = new MemoryStream())
{
ms.Write(byteArray, 0, (int)byteArray.Length);
using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(ms, true))
{
string documentText;
using (StreamReader reader = new StreamReader(wordDoc.MainDocumentPart.GetStream()))
{
documentText = reader.ReadToEnd();
}
documentText = documentText.Replace("##date##", DateTime.Today.ToShortDateString());
using (StreamWriter writer = new StreamWriter(wordDoc.MainDocumentPart.GetStream(FileMode.Create)))
{
writer.Write(documentText);
}
}
File.WriteAllBytes(saveFile.ToString(), ms.ToArray()); …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用python-docx模块替换文件中的单词并保存新文件,但需要注意新文件必须具有与旧文件完全相同的格式,但替换单词.我该怎么做?
docx模块有一个saveocx,它有7个输入:
除了替换的单词外,如何将原始文件中的所有内容保持不变?
我正在.docx使用模板创建文件PHPWord.它工作正常,但现在我想将生成的文件转换为PDF.
首先我尝试tcpdf结合使用PHPWord
$wordPdf = \PhpOffice\PhpWord\IOFactory::load($filename.".docx");
\PhpOffice\PhpWord\Settings::setPdfRendererPath(dirname(__FILE__)."/../../Office/tcpdf");
\PhpOffice\PhpWord\Settings::setPdfRendererName('TCPDF');
$pdfWriter = \PhpOffice\PhpWord\IOFactory::createWriter($wordPdf , 'PDF');
if (file_exists($filename.".pdf")) unlink($filename.".pdf");
$pdfWriter->save($filename.".pdf");
Run Code Online (Sandbox Code Playgroud)
但是当我尝试加载文件以将其转换为PDF我在加载文件时遇到以下异常
致命错误:未捕获的异常'BadMethodCallException',消息'无法在Section中添加PreserveText.'
经过一些研究后我发现其他一些人也有这个bug(phpWord - 无法在Section中添加PreserveText)
编辑
在尝试了一些后,我发现,
Exception只有当我mail merge fields在我的文档中有一些时才会发生.一旦我删除它们Exception就不再出现了,但转换后的
我想过用另一种方法生成PDF,但我只能找到4种方法:
PHPWord和更好tcpdf,但仍然不能用作图像丢失,以及大多数(不是全部!)的样式有没有第五种方法来生成PDF?或者是否有任何解决方案可以使生成的PDF文档看起来不错?
有没有一种简单的方法可以从Linux服务器上的命令行将HTML(带CSS样式和嵌入图像)转换为ODT,DOCX,DOC.我搜索了很多,但没有找到一个好的选择.转换为PDF的方法存在问题,由wkhtmltopdf决定.也许有办法将生成的PDF文档转换为其他格式?
好吧,我已经知道有一个关于此的文件,其中说明:
12.2.4.26 Relationships Transform Algorithm
13 The relationships transform takes the XML document from the Relationships part and converts it to another
14 XML document.
15 The package implementer might create relationships XML that contains content from several namespaces, along
16 with versioning instructions as defined in Part 5: “Markup Compatibility and Extensibility”. [O6.11]
17 The relationships transform algorithm is as follows:
18 Step 1: Process versioning instructions
19 1. The package implementer shall process the versioning instructions, considering that …Run Code Online (Sandbox Code Playgroud) 我正在使用Python docx库来生成一个文档,我希望能够打开并找到拼写错误.但是当我打开文档时,没有任何拼写错误标记(小红色下划线)或者如果我确定进行拼写检查.如果我编辑一行或副本,将内容剪切并粘贴到单词中,拼写功能将按预期工作.
有没有办法让输出文档自动显示/识别输出文档中的拼写错误?我玩过"no_proof"标志,但似乎没有帮助.(在Windows框中使用64位Python 3.4,docx 8.6,在Word 2013中打开输出)
谢谢你的任何想法!
代码重现:
from docx import Document
document = Document()
paragraph = document.add_paragraph('This has a spellling errror')
document.save(r'SpellingTester.docx')
Run Code Online (Sandbox Code Playgroud)