Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,028

HOME > ASP > ASP Forum > ผมอยากให้ Asp แสดงผลออกมาเป็น MS Word ได้หรือเปล่าครับ



 

ผมอยากให้ Asp แสดงผลออกมาเป็น MS Word ได้หรือเปล่าครับ

 



Topic : 001842

Guest




คือผมเคยเห็นวิธีการที่ Asp แสดงผลออกมาเป็น MS Excel มาแล้ว แต่ยังไม่เคยเห็นวิธีที่ให้ผลออกมาเป็น MS Word เลยครับ มันมีคำสั่งในการแสดงอย่างไรครับ


Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 28 ต.ค. 2547 15:40:37 By : tuntigon View : 3571 Reply : 7
 

 

No. 1



โพสกระทู้ ( 94 )
บทความ ( 0 )



สถานะออฟไลน์


ผมไปหาเจอแล้ว อยากให้เพื่อน ๆ ที่ยังไม่รู้ดูเป็นตัวอย่างนะครับ
ASP to MSWord

Microsoft Word 97 (and better) can interpret html. In order to open MSWord on the client and direct html output to Word rather than standard browser output you must change the content type. Response.ContentType = "application/vnd.ms-word" will open Word inside of the browser and html will appear inside a new word document. The Word document generated can changes and modified just like any other Word document. The following example utilizes our db of Mark ?The Bird? Fidrych?s career statistics and will output a basic html table inside of Word.
?View the Output
?Text View
?Print View
?Mail this Link
?Download the Code
? View the Data


<%
' Waits until all the asp is done before dumping the text to the browser
response.buffer = true

dim accessdb, cn, rs, sql
' Name of the Accessdb being read
accessdb="fidrych"

' Connect to the db with a DSN-less connection
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)

' Create a server recordset object
Set rs = Server.CreateObject("ADODB.Recordset")

' Select all data from the table the_bird
sql = "select * from the_bird "

' Execute the sql
rs.Open sql, cn
%>

<%
' Tells the browser to open word
Response.ContentType = "application/vnd.ms-word"
' Adds a header to give the document a name
response.AddHeader "content-disposition", "inline; filename=dynamicbb.doc"
%>
<html>
<body>
<table BORDER="1" align="center">
<tr>
<td>Year</td>
<td>Team</td>
<td>W</td>
<td>L</td>
<td>G</td>
<td>GS</td>
<td>CG</td>
<td>IP</td>
<td>H</td>
<td>BB</td>
<td>SO</td>
<td>ShO</td>
<td>ERA</td>
</tr>

<%
' Move to the first record
rs.movefirst

' Start a loop that will end with the last record
do while not rs.eof
%>

<tr>
<td>
<%= rs("year") %>
</td>

<td>
<%= rs("team") %>
</td>

<td>
<%= rs("w") %>
</td>

<td>
<%= rs("l") %>
</td>

<td>
<%= rs("g") %>
</td>

<td>
<%= rs("gs") %>
</td>

<td>
<%= rs("cg") %>
</td>

<td>
<%= rs("ip") %>
</td>

<td>
<%= rs("h") %>
</td>

<td>
<%= rs("bb") %>
</td>

<td>
<%= rs("so") %>
</td>

<td>
<%= rs("sho") %>
</td>

<td>
<%= rs("era") %>
</td>
</tr>

<%
' Move to the next record
rs.movenext
' Loop back to the do statement
loop %>
</table>

</html>

<%
' Close and set the recordset to nothing
rs.close
set rs=nothing

response.flush
response.end
%>

ประเภทของ Content Types

vnd.ms-excel - For Excel
vnd.ms-powerpoint - For PowerPoint
vnd.ms-project - For Microsoft Project
pdf - For Adobe Acrobat Documents
rtf - For Rick Text Documents
vnd.lotus-wordpro - For WordPro
vnd.lotus-1-2-3 - For Lotus 1-2-3
vnd.visio - For Visio
jpeg - for JPG Image File
gif - for GIF Image File
png - for PNG Image File

ลอง ๆ เอาไปประยุกต์ใช้ดูนะครับ คงมีประโยชน์กับเพื่อน ๆ ไม่มากก็น้อย....






Date : 28 ต.ค. 2547 15:55:57 By : tuntigon
 


 

No. 2



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ปกติแล้ว แค่ประกาศ ตัวที่ใว้ในส่วนของ header ก็น่าจะได้แล้วนะครับ

<%
Response.ContentType = "application/vnd.ms-word"
response.AddHeader "content-disposition", "inline; filename=dynamicbb.doc"
%>

Date : 28 ต.ค. 2547 18:31:25 By : @W_IN
 

 

No. 3



โพสกระทู้ ( 94 )
บทความ ( 0 )



สถานะออฟไลน์


ใช้แล้วครับ คือผมอยากจะแสดงตัวอย่าง ให้ผู้ที่ยังไม่เคยใช้ได้ดูเท่านั้นเองครับ ขอบคุณมากครับ
Date : 29 ต.ค. 2547 09:00:26 By : tuntigon
 


 

No. 4

Guest


ลองทำดูมีปํญหาถามหน่อยครับจากตัวอย่างถ้านำโปรแกรมไปติดตั้งที่เครื่อง Server ถ้าเครื่อง Server ไม่ได้ลง MS office ก็จะเปิดโปรแกรมไม่ได้ครับ เวลาเครื่องลูกเปิด ทำไมมันไม่ไปหา MS word ที่เครื่องลูกครับ
Date : 16 พ.ย. 2547 13:05:21 By : add
 


 

No. 5



โพสกระทู้ ( 31 )
บทความ ( 0 )



สถานะออฟไลน์


ผมลองทำดูแบบ Excel แต่ติดปํญหาปริ้นไม่ได้ หรือว่าต้องเปิดหน้าใหม่(_Blank) Error code: The document in this Frame can not be printed as laid out. ต้องแก้ไขจุดไหนครับ
ขอบคุณครับ
Date : 2009-02-13 20:28:04 By : witt
 


 

No. 6



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ASP Word (Word.Application)
Date : 2009-04-24 22:48:31 By : webmaster
 


 

No. 7

Guest


ขอ code หรือ หลักการ การออกรายงานทาง
microsoft word, exel, PDF, Print Document
ของ visual studio 2005 ภาษาc#

ขอบคุนมากนะครับ
Date : 2009-07-02 12:59:41 By : add
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ผมอยากให้ Asp แสดงผลออกมาเป็น MS Word ได้หรือเปล่าครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 02
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่