Click here to Skip to main content
15,894,630 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: System.Web.HttpException: The state information is invalid for this page and might be corrupted. Pin
prabhakar dwivedi11-Jan-10 3:42
prabhakar dwivedi11-Jan-10 3:42 
QuestionHow to Get the ID of a Hidden Field in a grid Pin
Vimalsoft(Pty) Ltd11-Jan-10 2:00
professionalVimalsoft(Pty) Ltd11-Jan-10 2:00 
Questionneed to move rows up or down in Ultraweb grid Pin
priyagee11-Jan-10 1:18
priyagee11-Jan-10 1:18 
AnswerRe: need to move rows up or down in Ultraweb grid Pin
Vimalsoft(Pty) Ltd11-Jan-10 2:35
professionalVimalsoft(Pty) Ltd11-Jan-10 2:35 
GeneralRe: need to move rows up or down in Ultraweb grid Pin
priyagee11-Jan-10 18:27
priyagee11-Jan-10 18:27 
Questionhow to read the string and get the src of image in whole string Pin
Niraj00111-Jan-10 1:00
Niraj00111-Jan-10 1:00 
AnswerRe: how to read the string and get the src of image in whole string Pin
Dinesh Mani11-Jan-10 1:14
Dinesh Mani11-Jan-10 1:14 
Questionexport excel to pdf formate in c# Pin
Pankaj Saha10-Jan-10 23:43
Pankaj Saha10-Jan-10 23:43 
Hi, I have an asp.net web application. I have an excel sheet and I have to export that excel sheet to a pdf file. I have done it, but still facing some problems.
1. Whenever I do export, its open excel file. I do not want to open the excel file.
2. I have to convert the pdf file to landscape.

Here is the code

private void ExportExcelToPDF()
        {


            string sourceFilePath = Server.MapPath("~/aaa.xlsx");
            string destinationFilePath = Server.MapPath("~/aaa.pdf");

            Microsoft.Office.Interop.Excel.Application myExcelApp;

            Microsoft.Office.Interop.Excel.Workbooks myExcelWorkbooks = null;

            Microsoft.Office.Interop.Excel.Workbook myExcelWorkbook = null;

            try
            {

                object misValue = System.Reflection.Missing.Value;

                myExcelApp = new Microsoft.Office.Interop.Excel.ApplicationClass();

                myExcelApp.Visible = true;
                object varMissing = Type.Missing;

                myExcelWorkbooks = myExcelApp.Workbooks;


                //if file already exist then delete the file
                if (System.IO.File.Exists(destinationFilePath))
                {
                    System.IO.File.Delete(destinationFilePath);
                }

                myExcelWorkbook = myExcelWorkbooks.Open(sourceFilePath, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue);

                myExcelWorkbook.ExportAsFixedFormat(Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF,
                    destinationFilePath, Microsoft.Office.Interop.Excel.XlFixedFormatQuality.xlQualityStandard,
                    varMissing, false, varMissing, varMissing, false, varMissing);

                myExcelWorkbooks.Close();

                myExcelApp.Quit();

            }
            catch
            {

            }
            finally
            {
                myExcelApp = null;
            }


        }


Pankaj

AnswerRe: export excel to pdf formate in c# Pin
Pankaj Saha11-Jan-10 0:09
Pankaj Saha11-Jan-10 0:09 
Questionhelp c# Pin
ptvce10-Jan-10 22:57
ptvce10-Jan-10 22:57 
Questionemail Pin
mylogics10-Jan-10 22:22
professionalmylogics10-Jan-10 22:22 
AnswerRe: email Pin
Vimalsoft(Pty) Ltd11-Jan-10 2:20
professionalVimalsoft(Pty) Ltd11-Jan-10 2:20 
GeneralRe: email Pin
mylogics11-Jan-10 19:35
professionalmylogics11-Jan-10 19:35 
GeneralRe: email Pin
Vasudevan Deepak Kumar12-Jan-10 4:09
Vasudevan Deepak Kumar12-Jan-10 4:09 
QuestionDelete record in Gridview Pin
Nopo10-Jan-10 21:46
Nopo10-Jan-10 21:46 
AnswerRe: Delete record in Gridview Pin
Dinesh Mani10-Jan-10 22:14
Dinesh Mani10-Jan-10 22:14 
GeneralRe: Delete record in Gridview Pin
Nopo10-Jan-10 22:36
Nopo10-Jan-10 22:36 
GeneralRe: Delete record in Gridview Pin
Dinesh Mani10-Jan-10 22:50
Dinesh Mani10-Jan-10 22:50 
GeneralRe: Delete record in Gridview Pin
Nopo10-Jan-10 22:59
Nopo10-Jan-10 22:59 
GeneralRe: Delete record in Gridview Pin
Dinesh Mani10-Jan-10 23:05
Dinesh Mani10-Jan-10 23:05 
GeneralRe: Delete record in Gridview Pin
Nopo10-Jan-10 23:23
Nopo10-Jan-10 23:23 
GeneralRe: Delete record in Gridview Pin
Dinesh Mani10-Jan-10 23:32
Dinesh Mani10-Jan-10 23:32 
AnswerRe: Delete record in Gridview Pin
Nopo11-Jan-10 2:51
Nopo11-Jan-10 2:51 
GeneralRe: Delete record in Gridview Pin
Dinesh Mani11-Jan-10 18:35
Dinesh Mani11-Jan-10 18:35 
QuestionProblem with Remember password Pin
Sudhanshu Mani Tripathi10-Jan-10 19:33
Sudhanshu Mani Tripathi10-Jan-10 19:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.