问题描述
我在弄清楚如何使用单词范围时遇到了麻烦.我有要添加到Word文件中的图片文件,但是我不知道如何在图片之间添加文本和表格.我想要的结构是这样的:文本,表格,图片.然后重复.
I'm having trouble figuring out how to work with word ranges. I have picture files that I am adding to a word file, but I can't figure out how to add text and tables in between the pictures. The structure I want is this: Text, table, picture. Then repeat.
但是,当我添加文本或表格时,它们全部都添加在四张图片之后,它们位于文件的顶部.我一直在阅读,并且发现需要使用范围来指定要放置表格/文本的位置,但是我发现的所有资源仅在页面顶部显示了如何添加.
However, when I add text or tables, they all area added after the four pictures, which stay at the top of the file. I've been reading and I've figured out I need to use ranges to specify where you want to place the tables/text, but all the resources I found only show how to add at the top of the page.
表格: http://msdn.microsoft.com/zh-cn/库/w1702h4a.aspx 文字: http://msdn.microsoft.com/en-us/library/6b9478cs .aspx
这是我添加图片的方式:
This is how I add pictures:
Word.Application wdApp = new Word.Application();
wdApp.Visible = true;
Document doc = wdApp.Documents.Add();
foreach (var category in type){
// add table/text
doc.Application.Selection.InlineShapes.AddPicture(@path + "\\" + category + "_" + DateTime.Now.ToString(datePatt) + ".jpg");
}
我希望能够在图片之前添加文本/表格,但是似乎我必须在文件中指定范围.我该怎么办?
I expected to be able to add my text/table before the picture, but it seems I have to specify ranges in the file. How can I do this?
推荐答案
这可能是您以前的问题之一的重复:
This is a possible duplicate of one of your previous questions: How to add items one at a time to to a new line a word document using word interop
在此处查看我以前对类似问题的回答: https://stackoverflow.com/a/12751805/700926 -它简要说明了如何完成此操作以及C#中的完整示例实现.
See my previous answer to your similar question here: https://stackoverflow.com/a/12751805/700926 - it gives a short explanation of how to accomplish this as well as a complete sample implementation in C#.
这篇关于使用interop.word范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!