Web Forms :: Displaying Word & Excel 2007 Documents?
Jul 22, 2010
I am loading documents into our Oracle database and then retrieving them for the users to view. So far PDF, DOC, XLS, CSV, etc. all perform as expected, however; DOCX, XLSX, etc. files have one annoyingly persistent issue. When the document is downloaded by the user and they open it you get the first in a series of messages: The file 'thefile.docx' cannot be opened because there are problems with the contents. Details: The file is corrupt and cannot be opened. and then: Word found unreadable content in 'thefile.docx'. Do you want to recover the contents of this document? If you trust the source, click Yes. After clicking yes the file opens and all of the content appears correct. Including images, formatting, tracked changeds and comments, equations, etc. I have tried multiple methods along these lines to no avail. I simply want the files to open without the false-positive error messages. I am using VS2010, with the website targeted at .Net Framework 2.0.
objConn =
New
OracleConnection(gstrConnectionString)
objConn.Open()
cmd = New
OracleCommand
cmd.Connection = objConn
cmd.CommandText = "select DOCUMENT_NAME,DOCUMENT_TYPE,DOCUMENT
from DOCUMENT_TABLE where DOCUMENT_ID='"
& strDocumentID & "'"
dr = cmd.ExecuteReader
dr.Read()
I am loading documents into our Oracle database and then retrieving them for the users to view. So far PDF, DOC, XLS, CSV, etc. all perform as expected, however; DOCX, XLSX, etc. files have one annoyingly persistent issue.
When the document is downloaded by the user and they open it you get the first in a series of messages:
The file 'thefile.docx' cannot be opened because there are problems with the contents.
Details: The file is corrupt and cannot be opened.
and then:
Word found unreadable content in 'thefile.docx'. Do you want to recover the contents of this document? If you trust the source, click Yes.
After clicking yes the file opens and all of the content appears correct. Including images, formatting, tracked changeds and comments, equations, etc.
I have tried multiple methods along these lines to no avail. I simply want the files to open without the false-positive error messages.
I am using VS2010, with the website targeted at .Net Framework 2.0.
objConn = New OracleConnection(gstrConnectionString) objConn.Open()
I am using the below code to Export DataTable to Word,Excel,CSV format & it's working fine. But problem is that this code export to MS Word 2003,Excel 2003 & CSV version. I need to Export my DataTable to MS Word 2007,Excel 2007 & CSV because I am supposed to handle more than 100,000 records at a time and as we know Excel 2003 supports for only 65,000 records.
how to export DataTable or DataSet to MS Word 2007,Excel 2007 & CSV.
I'm working on a web app and need to stream various files. I can do pdfs, images, and older Office documents. However, when I try to do with 2007 documents, it breaks. Here is my code:
Response.Buffer = true; Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); switch (FileExtension.ToLower()) { case "pdf": Response.ContentType = "application/pdf"; break; case "doc": Response.ContentType = "application/msword"; break; case "docx": Response.ContentType = "application/vnd.ms-word.document.12"; break; case "xls": Response.ContentType = "application/vnd.ms-excel"; break; case "xlsx": Response.ContentType = "application/vnd.ms-excel.12"; break; default: Response.ContentType = "image/jpeg"; break; } Response.BinaryWrite(buffer);
The error that I get is:
An invalid character was found in text content. Error processing resource 'http://DomainName/GetFile.aspx.
I am using the below code to Export DataTable to MS Word,Excel,CSV format & it's working fine. But problem is that this code export to MS Word 2003,Excel 2003 version. I need to Export my DataTable to Word 2007,Excel 2007,CSV because I am supposed to handle more than 100,000 records at a time and as we know Excel 2003 supports for only 65,000 records.
how to export DataTable or DataSet to MS Word 2007,Excel 2007.
I am retrieving a word 2010 document that has been uploaded to a sql 2005 database. When I subsequently download and open the document in a word window it states the file is corrupted and gives the user the option of repairing the file for display. This always works fine but the corrupted message is always presented for all DOCX files. The DOC files from an older Word version work fine without incident. the section of code, VB.NET, for streaming the document out to display in Word is:
Where the content type value, in this case, is "application/vnd.openxmlformats-officedocument.wordprocessingml.document" (rather than "application/vnd.ms-word").
The filename is simply the full name of the document and the data itself is loaded into the Bytes var. I got some time back... it just doesn't like the new and improved word 2010 files.
I'm hoping this is an easy one...I'm using Microsoft.Office.Interop.Word to convert uploaded word documents into previewable html files. I haven't implemented it fully, but I've played around with it enough that I think I have a plan that will work... My question revolves around
[Code]....
I'm not in love with the idea of opening word and closing it everytime there's an upload (which I hope is a lot of the time) I'd like to make this a shared object that loads at application start. I have 2 questions that go along with this. 1. I imagine that winword could lock up and that would be a problem, right? 2. to save a document I use wordapp.ActiveDocument, this could have an issue as a shared object, right? I think I'm talking myself right out of this...
when I click on gif and txt file links I can see Image and content of txt file in page and their address in address bar but by clicking on swf and png files link download dialog box appear? I need to remove this type of files from htaccess and I searched and found the Equivalent of htaccess is authorization section of web.config but I don't know..I need when click link I can see file and it's address in address bar.
I am trying to manipulate the XML of a Word 2007 document in C#. I have managed to find and manipulate the node that I want but now I can't seem to figure out how to save it back. Here is what I am trying:
// Open the document from memoryStream Package pkgFile = Package.Open(memoryStream, FileMode.Open, FileAccess.ReadWrite); PackageRelationshipCollection pkgrcOfficeDocument = pkgFile.GetRelationshipsByType(strRelRoot); foreach (PackageRelationship pkgr in pkgrcOfficeDocument) { if (pkgr.SourceUri.OriginalString == "/") [code]...
I'm looking for a way to export a Word document as a PDF. I would like to do this without the use of a "software printer" (such as CutePDF, etc.) and stick to reference assemblies if at all possible. I'm using Microsoft Office Interop Assemblies to generate a Word Document which I save to a temporary directory. So its not necessary for this solution to interact directly with Microsoft Office, unless it needs to.
I have a need for users to be able to edit word documents from my web page.
Are there any editors, or components, that will allow me to do this?
A bit of background, the user will be able to upload a word document to my site and then view/edit it from there. There will be no requirement for the user to download the document again but ideally I'd like to keep the document as a word doc at my end.
On Previous version of my application, if I want to export my data from SQL Server to Excel 2003 file, I just retrieve data from the SQL server and then straight away show "Open, Save, Cancel" dialog box to get the data on Excel 2003 Format. Here is the existing code in C#.
public void ExportToExcel(string StrFileName, DataTable dt) { if (dt!= null && dt.Rows.Count > 0)[code]....
but when I want to Export to Excel 2007 format with the same. I don't have any Idea to export it.
The file you are trying to open is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?
When yes is clicked it opens in excel but in some other format I think for I cannot AUTOSUM or sum the values result always as zero for numbers appears as text as " 222" . even if i try to format cells with numbers it does not works.
My users like to upload password-protected Word documents into our custom document management system. I'd like to add a validation to check for the password and refuse the upload if it has a password.
Automating Word - with COM interop - is out of the question because this is a server side application.
in my web application page i have a option to export to excel . I am able to export the data to Excel but have 2 issues
1) i hav ethe option of exporting in .XLS or .XLSX format
i am able to export in .xls format from any system ie the system having office 2007 or 2003
but when i am trying to export in .XLSX format i get error
Microsoft Office Excel---------------------------The file you are trying to open, 'noup.xlsx', is in a different format than specified by the file extension. Verify that the file is not corrupted and that the file extension matches the file format---------------------------Ok---------------------------
2) when exporting i want the excel sheet to be saved with the name thats selected from a dropdown
suppose the dropdown has text selected as CITY
i want the excel sheet as CITY.XLS/.XLSX
i my developemnet system it works fine with below code
string filename = dropdown1.SelectedItem.Text if (Extension.SelectedValue.ToString() == ".xls") {
[Code].....
but on production server i get the name of .aspx page
I'm having some difficulty merging multiple word documents together using Microsoft Office Interop Assemblies (Office 2007) and ASP.NET 3.5. I'm able to merge the documents, but some of my formatting is missing (namely the fonts and images). My current merge code is shown below.