Solved

How to read word document in ASP.net

Posted on 2014-09-14
4
505 Views
Last Modified: 2014-09-16
Hi,

I am trying to read content from word document using asp.net.can u plz give me example how to read word document.

Any software or dll's are required for this?
if there can you please give those details also
0
Comment
Question by:mannevenu26
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 21

Assisted Solution

by:Dale Burrell
Dale Burrell earned 375 total points
ID: 40322485
It does depend exactly what you are trying to do, and what version of Word you need to support. In most cases it will be easier to use a 3rd party component. One I have used is http://www.aspose.com/.net/word-component.aspx

If you only need to handle docx files then OpenXML (which is free) may do the job, but its more complex (in my experience) http://msdn.microsoft.com/en-us/library/office/bb448854(v=office.15).aspx

HTH
0
 

Author Comment

by:mannevenu26
ID: 40322493
we need both doc and docx.
Performance wise which one is better?OpenXML or Officeinteropt?

can u plz give sample code for both
0
 
LVL 12

Assisted Solution

by:Ramkisan Jagtap
Ramkisan Jagtap earned 125 total points
ID: 40322507
Sample code to open document with Microsoft.Office.Interop

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
        <asp:TextBox ID="TextBox1" runat="server" Height="722px" Width="100%"
            TextMode="MultiLine"></asp:TextBox>
   
    </div>
    <div>
   
        <asp:FileUpload ID="FileUpload1" runat="server" BorderStyle="Double"
            Width="549px" /> <asp:Button ID="Button1" runat="server" Text="Button"
            onclick="Button1_Click" />
   
    </div>
    </form>
</body>
</html>

Open in new window


protected void Button1_Click(object sender, EventArgs e)
      {
      
       
        Microsoft.Office.Interop.Word.ApplicationClass AC = new Microsoft.Office.Interop.Word.ApplicationClass();
        Microsoft.Office.Interop.Word.Document doc = new Microsoft.Office.Interop.Word.Document();
          object readOnly = false;
          object isVisible = true;
          object missing = System.Reflection.Missing.Value;
          try
          {
              doc = AC.Documents.Open(ref filename, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible);
              TextBox1.Text = doc.Content.Text;
          }
          catch (Exception ex)
          {
              MessageBox.Show("ERROR: " + ex.Message);
          }
          finally
          {
              doc.Close(ref missing, ref missing, ref missing);
          }
    }

Open in new window

0
 
LVL 21

Accepted Solution

by:
Dale Burrell earned 375 total points
ID: 40322617
Performance wise Aspose.Words is better...

MS themselves recommend not to use http://support.microsoft.com/kb/257757
0

Featured Post

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question