当前位置:首页 > 服务端 > Saving documents on server side.

Saving documents on server side.

来源:http://www.imcoder.org/enterprise-service/210201.htm

 

Q:

** Warning: possibly big newbie question below. **

Greetings,

Part of a web application I am developing involves generation of word documents (which I do using Word COM object) based on data provided by the client and then the application has to store them on the server.

However, I have yet to find the proper way in which to provide the paths needed both to save the document on the server and to load the template. I thought something like 'folder-to-store-stuff/document.doc' or '/folder-to-store-stuff/document.doc' would work but..well, it didn't (Folders exist on the application path, so it's not that they weren't created).

It is not a folder permission issue, the errors I get are that either the path is unreachable or that it cannot create the instance of Document because of not being able to find the path.

Any kind of help or directions would be greatly appreciated.

A:Hello, Can you please post some of your code so we can look at how your referenceing to the location of the folders.
A:

Greetings,

This is the method I created for the generation of the documents.

Sub

createDocument(ByVal empresa As String, ByVal contacto As String, ByVal pasante As String, ByVal tutor As String, ByVal duracion As String, ByVal desde As String, ByVal hasta As String)

Dim wa As New Word.ApplicationClass
Dim oTemplate As String = "/Documents/Templates/Template.dot"
Dim wd As Word.Document = wa.Documents.Add(oTemplate)
Dim ruta As String
ruta = "/Documents/Contract Documents/Contract" & AdministradorPasantias.getObject.getPasante.idPasante.ToString & AdministradorPasantias.getObject.getPasante.idPasantia.ToString & ".doc"

Try
   wd.Activate()
   'Assigns to each bookmark the corresponging value from the form.

   wd.Bookmarks.Item("observaciones").Range.Text = objInforme.observaciones
   
wd.Bookmarks.Item("empresa").Range.Text = empresa
   
wd.Bookmarks.Item("contacto").Range.Text = contacto
   
wd.Bookmarks.Item("pasante").Range.Text = pasante
   
wd.Bookmarks.Item("duracion").Range.Text = duracion
   
wd.Bookmarks.Item("tutor").Range.Text = tutor
   
wd.Bookmarks.Item("desde").Range.Text = desde
   
wd.Bookmarks.Item("hasta").Range.Text = hasta
   
wd.SaveAs(ruta)
   
wd.Application.Quit()
Catch ex As Exception

End Try
End Sub

The directory where I have the application has the corresponding "/Documents/Templates/" and "/Documents/Contract Documents/" inside.

Again, any kind of help will be greatly appreciated. I'm sure I must be missing something simple but..well, I'm stuck.

作者:KK in cnblog
来源链接:https://www.cnblogs.com/kangshifu/archive/2008/10/09/1306964.html

版权声明:
1、Java侠(https://www.javaxia.com)以学习交流为目的,由作者投稿、网友推荐和小编整理收藏优秀的IT技术及相关内容,包括但不限于文字、图片、音频、视频、软件、程序等,其均来自互联网,本站不享有版权,版权归原作者所有。

2、本站提供的内容仅用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯相关权利人及本网站的合法权利。
3、本网站内容原作者如不愿意在本网站刊登内容,请及时通知本站(javaclubcn@163.com),我们将第一时间核实后及时予以删除。





本文链接:https://www.javaxia.com/server/125329.html

分享给朋友: