Coder Social home page Coder Social logo

miniword's Introduction

mini-software

miniword's People

Contributors

eynarhaji avatar haozekang avatar imppdx avatar isdaniel avatar itldg avatar nvadera-sc avatar ping9719 avatar shps951023 avatar tukhfatov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

miniword's Issues

Table 內資料換行的問題

如果在表格內有換行資料時,產生出來的內容會多出好幾個換行

原本預期

index Second Header
1 line1
line2
line3

實際結果

index Second Header
1 line1

line2

line3


MiniWordPicture Path or Bytes bug

微信图片_20240104182804
微信图片_20240104182755
只传Bytes时,因Extension在解析Path 路径后缀报空指针,建议这里支持网络路径或者解决掉这个空指针问题

一种可能导致文本替换失效的情况

遇到很奇怪的情况,即使整个 {{tagname}} 使用格式刷,文本替换还是不生效。

查看document.xml,里面的实际情况为:

<w:r>
    <w:rPr>
        <w:rFonts w:hint="eastAsia" w:ascii="宋体" w:hAnsi="宋体" w:cs="宋体"/>
        <w:sz w:val="48"/>
        <w:szCs w:val="48"/>
    </w:rPr>
    <w:t>{</w:t>
</w:r>
<w:r>
    <w:rPr>
        <w:rFonts w:ascii="宋体" w:hAnsi="宋体" w:cs="宋体"/>
        <w:sz w:val="48"/>
        <w:szCs w:val="48"/>
    </w:rPr>
    <w:t>{type}}</w:t>
</w:r>

Samples中的Demo4也测试了类似的情况。

我写了下面一个小方法,(模仿AvoidSplitTagText),尝试处理这种情况:

private static void MergeTagInMultiText(OpenXmlElement xmlElement)
{
    var texts = new LinkedList<Text>(xmlElement.Descendants<Text>());
    var node = texts.First;
    while (node != null)
    {
        if (node.Next == null) goto next;
        var next = node.Next.Value;
        if (!node.Value.InnerText.EndsWith("{{") && node.Value.InnerText.EndsWith("{"))
        {
            if (next.InnerText.StartsWith("{") && !next.InnerText.StartsWith("{{"))
            {
                node.Value.Text = node.Value.InnerText + "{";
                next.Text = next.InnerText.Substring(1) ;
            }
        }
        else if (node.Value.InnerText.EndsWith("}") && !node.Value.InnerText.EndsWith("}}"))
        {
            if (next.InnerText.StartsWith("}") && !next.InnerText.StartsWith("}}"))
            {
                node.Value.Text = node.Value.InnerText + "}";
                next.Text =  next.InnerText.Substring(1);
            }
        }

        next:
        node = node.Next;
    }
}

AvoidSplitTagText之前使用这个方法处理了一下,之前不能渲染的地方可以正常渲染了(自己一个简单的例子)。

感觉大概是这种思路,将相邻的格子里面落单的}或者{跟前后的大部队合并起来,只是可能实现的粗糙了一点。

对于未来的功能设计建议

这是对于未来的功能设计建议
常用功能:

进度 功能 说明 用处/领域 代码建议
× 简单生成Word 文字,图片,表格,段落 简单文档,说明书,等要求不严格的地方 MiniWord.SaveAs(string path, object value, WordType wordType);
MiniWord.SaveAs(string path, WordInfo value, WordType wordType);
× 简单获取Word 可以按需求提取简单纯文字,图片,表格,段落 简单需要获取文档信息地方 WordInfo wordInfo = MiniWord.Query(string path);
× 简单合并Word 一个或多个合并为一个 MiniWord.Join(string path, params string[] path);
× 导出为指定格式 生成txt,简单html txt:简单翻译
html:简单在线预览
WordInfo.ToString()
WordInfo.ToHtml()
× 简单查找文本 有助于解决:标签{{}}会拆分为{{Tag}}的问题 private ??? Seek(string path, string value)
× 水印 生成简单文字水印,图片水印 提升逼格 MiniWord.SaveAs(string path, watermark : WordWatermark);
简单或复杂替换

附加:
https://www.cnblogs.com/ping9719/p/12462478.html

Supporting list formatting

Hi!

First of all - awesome library, thank you!

THe question about lists. Am I right that you are not creating a new list items, but adding rows to existing one? Template:
image

Result:
image

As U can see numbering for list is not working.

Paragraph replace by tag

                        <w:r>
                            <w:t>{{</w:t>
                        </w:r>
                        <w:proofErr w:type="spellStart"/>
                        <w:r>
                            <w:t>CreateDate</w:t>
                        </w:r>
                        <w:proofErr w:type="spellEnd"/>
                        <w:r>
                            <w:t>}}</w:t>
                        </w:r>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="1870" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w14:paraId="53105C06" w14:textId="07109D26" w:rsidR="00B721B4" w:rsidRDefault="00B721B4">
                        <w:r>
                            <w:t xml:space="preserve">{{Name}} has </w:t>
                        </w:r>
                        <w:r w:rsidRPr="005F3C0A">
                            <w:rPr>
                                <w:color w:val="FF0000"/>
                            </w:rPr>
                            <w:t xml:space="preserve">{{Points}} </w:t>
                        </w:r>
                        <w:r>
                            <w:t>points</w:t>
                        </w:r>
                    </w:p>
                </w:tc>

Split template string like `<w:t>{</w:t><w:t>{<w:/t><w:t>Tag</w:t><w:t>}</w:t><w:t>}<w:/t>` problem

        <w:p w14:paraId="00F3FAAC" w14:textId="2EB54515" w:rsidR="00D362CD" w:rsidRDefault="00D362CD">
            <w:r>
                <w:rPr>
                    <w:rFonts w:hint="eastAsia"/>
                </w:rPr>
                <w:t>{{Co</w:t>
            </w:r>
            <w:r>
                <w:t>ntent</w:t>
            </w:r>
            <w:r w:rsidR="001D405E">
                <w:t>}</w:t>
            </w:r>
            <w:r>
                <w:t>}</w:t>
            </w:r>
        </w:p>
        <w:p w14:paraId="71A906B0" w14:textId="7C726FC1" w:rsidR="00D362CD" w:rsidRDefault="00D362CD"/>
        <w:p w14:paraId="7FC15E02" w14:textId="3DD8C144" w:rsidR="00D362CD" w:rsidRDefault="00D362CD">
            <w:r>
                <w:t>{{Content2}</w:t>
            </w:r>
            <w:r>
                <w:rPr>
                    <w:rFonts w:hint="eastAsia"/>
                </w:rPr>
                <w:t>}</w:t>
            </w:r>
        </w:p>

Template Tag format string doesn't replace

image

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" xmlns:wpsCustomData="http://www.wps.cn/officeDocument/2013/wpsCustomData" mc:Ignorable="w14 w15 wp14">
    <w:body>
        <w:p>
            <w:pPr>
                <w:pStyle w:val="2" />
                <w:jc w:val="center" />
                <w:rPr>
                    <w:rFonts w:hint="eastAsia" w:eastAsia="宋体" />
                    <w:lang w:val="en-US" w:eastAsia="zh-CN" />
                </w:rPr>
            </w:pPr>
            <w:bookmarkStart w:id="0" w:name="_GoBack" />
            <w:bookmarkEnd w:id="0" />
            <w:r>
                <w:rPr>
                    <w:rFonts w:hint="eastAsia" w:eastAsia="宋体" />
                    <w:lang w:val="en-US" w:eastAsia="zh-CN" />
                </w:rPr>
                <w:t>My</w:t>
            </w:r>
            <w:r>
                <w:rPr>
                    <w:rFonts w:hint="eastAsia" w:eastAsia="宋体" />
                    <w:lang w:val="en-US" w:eastAsia="zh-CN" />
                </w:rPr>
                <w:t>{</w:t>
            </w:r>
            <w:r>
                <w:rPr>
                    <w:rFonts w:hint="eastAsia" w:eastAsia="宋体" />
                    <w:sz w:val="54" />
                    <w:szCs w:val="54" />
                    <w:lang w:val="en-US" w:eastAsia="zh-CN" />
                </w:rPr>
                <w:t>{</w:t>
            </w:r>
            <w:r>
                <w:rPr>
                    <w:rFonts w:hint="eastAsia" w:eastAsia="宋体" />
                    <w:lang w:val="en-US" w:eastAsia="zh-CN" />
                </w:rPr>
                <w:t>title</w:t>
            </w:r>
            <w:r>
                <w:rPr>
                    <w:rFonts w:hint="eastAsia" w:eastAsia="宋体" />
                    <w:lang w:val="en-US" w:eastAsia="zh-CN" />
                </w:rPr>
                <w:t>}}</w:t>
            </w:r>
        </w:p>
        <w:sectPr>
            <w:pgSz w:w="12240" w:h="15840" />
            <w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440" w:header="720" w:footer="720" w:gutter="0" />
            <w:cols w:space="720" w:num="1" />
            <w:docGrid w:linePitch="360" w:charSpace="0" />
        </w:sectPr>
    </w:body>
</w:document>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.