15,905,967 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Camects (Top 2 by date)
Camects
15-Jan-16 4:56am
View
You may (or may not) know this but I'd like to point out that the code that you posted in the below comments is not actually creating a DOC file:
Response.AddHeader("content-disposition", "attachment;filename=" + title + ".doc");
Response.Charset = "";
Response.ContentType = "application/ms-word";
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
gvExport.RenderControl(hw);
string style = @"<style> .textmode { mso-number-format:\@; } </style>";
Response.Write(style);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
What this does is it takes a HTML representation of a GridView and saves it as a file with a DOC extension. This is a sort of a workaround because MS Word is able to read and display that HTML file however when opening this file it will throw a warning that says that a file's format and extension are not the same. After you re-save it with MS Word then it will become a "real" DOC file.
Now depending on the situation this may not be an ideal solution, so as an alternative you can check out
how to convert a HTML content into a Word document in C#
.
Another alternative is this:
http://www.codeproject.com/Articles/91894/HTML-as-a-Source-for-a-DOCX-File
But note that this approach only works for MS Word. In other words the documents created by that approach will appear empty in any other Word application (except in MS Word).
Camects
14-Jan-16 4:58am
View
You can consider using
this Word library for C#
, for example like the:
var document1 = DocumentModel.Load("Sample1.pdf");
var table1 = (Table)document1.GetChildElements(true, ElementType.Table).First();
var document2 = DocumentModel.Load("Sample2.pdf");
var table2 = (Table)document2.GetChildElements(true, ElementType.Table).First();
var document = new DocumentModel();
document.Sections.Add(
new Section(document,
document.Import(table1, true),
document.Import(table2, true)));
document.Save("Merged Table Samples.pdf");
Also the following link contains another example of
reading a PDF file and extracting its text or table content in C#
. Additionally if interested this sample shows how you can
create a new PDF file in C#
from scratch.