16,017,351 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 .NET 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 MaureenMcDuffie (Top 2 by date)
MaureenMcDuffie
18-Jun-15 4:32am
View
Well you can try
this Excel's tool for .NET Framework
that I've been using for some time now. Its a quite straightforward, all you have to do in order to
convert an excel file into a pdf file with C# code
is the following:
ExcelFile.Load("Input.xlsx").Save("Output.pdf");
I've been using this on my windows service which runs every day and converts every spreadsheet type file (so .csv, .xls and .xlsx) into a PDF and uploads it to our repo.
MaureenMcDuffie
18-Jun-15 4:22am
View
You cannot export the
GridView
into an existing excel file with
HtmlTextWriter
. The only thing that you can do with it is export the HTML content of the
GridView
control into a new file which then you can name it with .xls extension. This is a known workaround which is useful in some cases and it works because most of the Excel applications (including MS Excel) will be able to open this file.
But in order to add a new sheet to an existing excel file you will have to go with some other approach. Unfortunately the Philippe's suggestion (using OpenXML SDK) will not suite you because that is able to manipulate with only .xlsx.
So instead take a look at
this
[
^
] article. That sample demonstrates how after using the
HtmlTextWriter
you can
convert that HTML content into an excel file in C#
.
Also take a look at how you can
read the existing excel (both .xls and .xlsx) files in C#
.
Note that both samples use the same
C# library for manipulating with excel files
.