Asp.net and WORD document

Hope to deal with WORD documents online
From the Internet to see a middleware way of incorporating WORD into your browser
This is how to achieve?

Started by Victoria at February 09, 2016 - 2:21 PM

Buy a middle price, very cheap, develop their own time-consuming

Posted by Arvin at February 24, 2016 - 3:19 PM

DSOFramer

Posted by Marsh at March 04, 2016 - 4:19 PM

Do something that is free, not to make money but not to lose ah, ha ha

Posted by Victoria at March 14, 2016 - 4:40 PM

Thank you, but it seems Microsoft website can not find this.

Posted by Victoria at March 22, 2016 - 4:45 PM

Now some website, can according to need to generate a WORD document and direct download

This is how to achieve?

Posted by Victoria at November 17, 2016 - 9:33 AM

The site generates WORD?

Posted by Marsh at November 26, 2016 - 9:38 AM

Generation of HTML into MHT suffix.

Source code

Posted by Marsh at December 11, 2016 - 10:38 AM

According to the contents of the database to generate documentation, and then directly is the pop-up download page

Posted by Victoria at December 23, 2016 - 11:16 AM

Use ASP.NET to generate Word documents and direct download
The following ideas
Step 1:
In this case, use the word component of MS (Microsoft.Office.Interop.Word.dll), so in the first project inside add reference, as shown in Fig.:

Add in the CreateWord.cs file.:

using System.Reflection;

using Microsoft.Office.Interop.Word;


Then add the following code in the button event.:

ApplicationClass wordApp = new ApplicationClass();

object missing = System.Reflection.Missing.Value;

object tempName = @"d:\Temp.dot"; // The template name, in the case of the template as behind a graph

object docName = @"D:\WebSite\a.doc"; // The generated word files, can not be placed in the web directory



// Generate a new document, here the use of the above-mentioned template, if you do not want to use the specified template, you can use the missing, it will use the default template. Several methods for generating word files, see MSDN

Document MyDoc = wordApp.Documents.Add(ref tempName, ref missing, ref missing, ref missing);



wordApp.Visible = true;

MyDoc.Activate();



wordApp.Selection.Font.Size = 30; // Font size

wordApp.Selection.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter; // In the middle

wordApp.Selection.Font.Bold = (int)WdConstants.wdToggle; // Blackbody



wordApp.Selection.TypeText("hello"); // Text content, here I have not read from the database, they only tested write



// Save the word document

MyDoc.SaveAs(ref docName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);



// Closed, release

MyDoc.Close(ref missing, ref missing, ref missing);

wordApp.Quit(ref missing, ref missing, ref missing);

MyDoc = null;

wordApp = null;



Response.Redirect("DownloadWord.aspx?id=" + "a.doc");

Download page code(DownloadWord.aspx.CS):

string FullFileName = Request.QueryString["id"];

FileInfo DownloadFile = new FileInfo(HostingEnvironment.ApplicationPhysicalPath + FullFileName); // Need to be converted to an absolute path, otherwise it will automatically recognize the C drive system in the IIS directory, and, unable to pass the URI approach to data stream to read. If you generate file is not in the web directory, also need to be explicit.

// The following is to read the file, the data stream mode Download.

Response.Clear();

Response.ClearHeaders();

Response.Buffer = false;

Response.ContentType = "application/octet-stream";

Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FullFileName, System.Text.Encoding.UTF8));

Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());

Response.WriteFile(DownloadFile.FullName);

Response.Flush();

Response.End();



Step 2:
Because a browser can download a file.
Therefore, in the background you to put this folder into the form of RAR, download it now.
Or use another method of.JS with the server
<script language=javascript>
function downFiles(arrFileName)
{
for(var i = 0;i <arrFileName.length;i++)
{
window.open( "downFile.aspx?fileName= " + arrFileName[i];
}
}
var arr = " <%=fileNames%> .split( ": ");
downFiles(arr);
//CS
public string fileNames
{
get
{
return "1.txt:2.txt:3.txt ";
}
}



Combining the two ideas: can make the ASP.NET client users to download multiple files

Posted by Megan at December 27, 2016 - 12:02 PM

Is there any way can be achieved online on WORD document for editing and storage.?

Posted by Victoria at January 05, 2017 - 1:50 PM

I give thought to it, you try JQuery board AJAX if you understand the Ajax should be able to do!

Posted by Alva at January 09, 2017 - 2:12 PM

But the technology has been developed to have a good solution, strongly recommended by PageOffice, the server is not installed Office, no automatic call, not only can the dynamic output anything you want the content to the word document, but also in the webpage in online display, edit word, excel. You don't have to worry about browser compatibility issues, the PageOffice supports IE, chrome, Firefox, Sogou, travel, 360 and so on all popular browsers
The office component is very exciting ah, for the landlord only drawback is that charges

Posted by Joshua at January 10, 2017 - 1:10 PM

Proposed landlord to query the Aspose.words third party controls, can output word, read word, save as HTML, etc.. Function is very powerful.

Posted by Phyllis at January 11, 2017 - 12:58 PM