15,887,927 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 prahalad.gaggar (Top 13 by date)
prahalad.gaggar
12-Dec-12 8:19am
View
That's using PHP. Tried it!!! Not useful!!
prahalad.gaggar
6-Dec-12 9:08am
View
@nyab31 please check my answer!!!
i think now i am generating a valid Excel(.xlsx) file!!!
prahalad.gaggar
6-Dec-12 9:06am
View
your code cannot be deployed deployed on cloud, because office automation is illegal on asp.net, for that u have to use share-point!!!
which is very tedious!!!
prahalad.gaggar
6-Dec-12 9:00am
View
Doesn't it takes time if you have a data-table with more than 500 records!!!
prahalad.gaggar
6-Dec-12 8:51am
View
Very Untidy code, also takes a lot time to generate the excel file!!!
10 - 15 secs just to enter 800 records!!!
I edited the code:
protected void to_excel(object sender, EventArgs e)
{
string filepath = Path.Combine(Server.MapPath("~/Files"), fileupload.FileName);
fileupload.SaveAs(filepath);
string fname = fileupload.PostedFile.FileName;
DataTable dt = (DataTable)ReadToEnd(filepath);
string sFilename = fname.Substring(0, fname.IndexOf("."));
sFilename = sFilename + ".xlsx";
Microsoft.Office.Interop.Excel._Application app = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel._Workbook workbook = app.Workbooks.Add(Type.Missing);
Microsoft.Office.Interop.Excel.Worksheet objSheet = new Microsoft.Office.Interop.Excel.Worksheet();
Microsoft.Office.Interop.Excel.Workbook objWorkBook = null;
app.Visible = true;
objSheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Sheets["Sheet1"];
objSheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.ActiveSheet;
objSheet.Name = "Sheet1";
int col = 1;
int row = 1;
foreach (DataColumn column in dt.Columns)
{
objSheet.Cells[row, col] = column.ColumnName.ToString();
col++;
}
col = 1;
row = 2;
foreach (DataRow rw in dt.Rows)
{
foreach (DataColumn cl in dt.Columns)
{
if (rw[cl.ColumnName] != DBNull.Value)
objSheet.Cells[row, col] = rw[cl.ColumnName].ToString();
col++;
}
row++;
col = 1;
}
workbook.SaveAs(sFilename, Microsoft.Office.Interop.Excel.XlFileFormat.xlXMLSpreadsheet, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
}
Also i don't know how to auto save the result!!!
Total Waste, this code won't work in real world!!!
Better to use my solution. (I am not saying this because i found the solution, but after comparing your result with mine i came to this conclusion)
No hard Feelings bro!!!
And I appreciate your help!!!
Keep Smiling :)
prahalad.gaggar
6-Dec-12 8:36am
View
@Deenuji: your code is too untidy!!!
also is your code returning xlsx file???
Even your "For" loops are not working as "dataGridView1.Rows.Count" is not valid!!!
prahalad.gaggar
5-Dec-12 10:16am
View
thanks...i have 1 more question : how can we reduce the size of an existing pdf only with programically (c# 3.5)....i don't wish to use paid library to do so...i can provide you with the sample pdf http://pdfcast.org/pdf/insured-lloyds
prahalad.gaggar
5-Dec-12 10:01am
View
I see, then what is the correct way to convert a text (tab deliminator) to an excel (.xlsx) file!!!
very very well said sir!!!
actually i could have solve the problem just by renaming the text file abc.txt to abc.xls but i created a data-table for it!!!
prahalad.gaggar
5-Dec-12 9:16am
View
Well said sir...let me be more specific
It contains data to generate the a insurance policy with black and white images (around 2-3 including all the 50 docs collectively).
prahalad.gaggar
4-Dec-12 2:03am
View
your heading is very wrong!!!
it should be how to reduce the size of pdf while generating from TIF ?
people gets confused with the current header as how to reduce size of a pdf stored in disk!!!
and please link this question to Top Exports to find the solution as I am also having a similar question!!!
prahalad.gaggar
3-Dec-12 7:46am
View
Reason for my vote of 1 \n while writing an article one should avoid using of tools.
As this tools can't be used everywhere even though they are available for free!!!
prahalad.gaggar
30-Nov-12 4:14am
View
One must have research it from his side and after getting nothing from useful from his research, then and then only one should have asked the question. This is what one must have done (From my point of view).
you are saying about lazy, i don't think that lazy people can survive in this field.
What i requested from you is that one must not give random links.
As in your case u said the first link from from Google search.
I want to say that link from google search keep on changing (i think you know that), so i thought one must not give such links!!!!
Hope that goes well with you!!!
prahalad.gaggar
29-Nov-12 4:31am
View
why can't u provide us with the code!!!!
one should always avoid links while replying answer to a Question!!!
Show More