使用从SQL检索的信息填充.doc模板 [英] Filling a .doc template with information retrieved from SQL

查看:75
本文介绍了使用从SQL检索的信息填充.doc模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!



我有一个简单的问题...我想LOL



我拥有:一个C#Windows窗体应用程序,用于插入,更新和检索SQL数据库中的信息。我在这里的论坛上发现了很多有用的信息,到目前为止,项目进展顺利。我不打算出售或分发它,这只是为了我的小企业。我甚至可以编制一个将数据传输到我的会计软件的POS。



所以...项目已经结束了,但现在我希望能够打印我的合同和发票。我有一个合同模板(我现在用手填写),它在.doc



我想知道什么是最好的(隐形和无声) )在我的文档中插入数据的方法。通过隐形和无声,我的意思是我不想像Word那样打开并且必须在那里点击打印。



我只想按下打印按钮,获取数据,让C#将其插入模板并打印出来。



到目前为止,我知道我必须构建一个模板doc文件(保存在其中)格式?)



我看过帖子和一些关于使用它的MSDN:



 WordApplication.ActiveDocument.Bookmarks [  BookmarkName]。



但我无法弄清楚我是否能得到我想要的结果。



再一次,谢谢非常感谢你的帮助。我不能说我多么欣赏它。

我正在寻找新帖子并试图帮助人们,如果可以的话,但我仍然是一个菜鸟。我有一天会去那里,我将能够帮助回来*承诺*

解决方案

引用:

我想知道在我的文档中插入数据的最佳(隐形和无声)方式是什么。





将所有代码放入一个单独的线程会使它隐形而无声



引用:

我只想按下打印按钮,获取数据,将C#插入模板并打印出来。





他们无需按下按钮,因为你可以使用打印对话。



另外

 WordApplication.ActiveDocument.Bookmarks [BookmarkName] 

就是你有一个word文档插件应用程序。



如果我是你,我会而是使用一个隐藏的richtext框作为你的模板(所以没有人看到它)并用数据做你想做的事。


Hi everyone !

I have a simple question ... I think LOL

I have : a C# Windows Form App that inserts, updates and retrieves information from an SQL Database. I've found a lot of useful information on the forums here and so far, the project is going pretty well. I don't plan on selling it or distributing it btw, it's just for my small business. I was even able to program a POS that transfers data to my accounting software.

So.. the project is almost over, but now I'd like to be able to print my contracts and invoices. I have a contract template (that I fill out by hand at the moment), it's in .doc

I'd like to know what the best (invisible and silent) way to insert data in my documents would be. By invisible and silent, I mean I don't want like Word to open and have to click print in there.

I'd just like to push a print button, fetch the data, have C# insert it into the template and print it.

So far, I know I have to build a template doc file (save it in which format?)

I've read posts and a little MSDN about using this:

WordApplication.ActiveDocument.Bookmarks["BookmarkName"] .


but I can't figure out if I'll get the results I want with that.

Once again, thank you very much for the help. I can't say enough about how much I appreciate it.
I'm looking around the new posts and trying to help people if I can, but I'm still a "noob". I'll get there someday and be I"ll be able to help back *promise*

解决方案

Quote:

I'd like to know what the best (invisible and silent) way to insert data in my documents would be.



Putting all of your code into a separate thread would make it "invisible and silent"

Quote:

I'd just like to push a print button, fetch the data, have C# insert it into the template and print it.



Their is no need to push a button because you can use a print dialogue.

Also

WordApplication.ActiveDocument.Bookmarks["BookmarkName"]

is when you have a word document plug in application.

If I were you I would instead use a hidden richtext box be your template (so nobody see's it) and do what you want with the data.


这篇关于使用从SQL检索的信息填充.doc模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆