Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 3rd, 2005, 06:13 AM
Registered User
 
Join Date: Oct 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Excel Application

I have an application whr i pass around 300000 values to the below method to genarate the output in an excel file.. problem is my code is giving the output only for the last input alone.... plz help me in solving this........

thanks to u all in advance.......

private void GetHospitals(int[] RecordNumbers)
        {
            DataTable HospitalDataTable = Map1.Layers["hospital"].DataQuery(RecordNumbers, true);
            HospitalDataTable.Columns.Add("ZipCode");
            int[] ZipRecordNumbers = new int[0];

            foreach (DataRow record in HospitalDataTable.Rows)
            {
                ZipRecordNumbers = Map1.Layers["zip_poly"].SpatialQuery((BaseShape)record["MapSuiteShape"], MapSuite.SpatialQueryContainment.Contained);
                record["ZipCode"] = Map1.Layers["zip_poly"].DataQuery(ZipRecordNumbers[0], "ZIP");

            }

            try
            {
                string dstfile= "c:\\HospitalZipcodeList.xls";
                Excel.Application excel= new Excel.Application();
                Excel._Worksheet wsheet;
                Excel._Workbook wbook;
                excel.Visible=false;
                int rowIndex=1;
                int colIndex=0;
                wbook =(Excel._Workbook)(excel.Workbooks.Add(true));
                wsheet=(Excel._Worksheet)wbook.ActiveSheet;
                //excel.Application.Workbooks.Add(true);
                //DataTable table=new DataTable();


                foreach(DataColumn col in HospitalDataTable.Columns)
                {
                    colIndex++;
                    wsheet.Cells[1,colIndex]=col.ColumnName;

                }

                foreach(DataRow row in HospitalDataTable.Rows)
                {
                    rowIndex++;
                    colIndex=0;
                    foreach(DataColumn col in HospitalDataTable.Columns)
                    {
                        colIndex++;
                        wsheet.Cells[rowIndex,colIndex]=row[col.ColumnName].ToString();
                    }
                }

                excel.Visible=true;
                wbook.SaveAs(dstfile,Excel.XlFileFormat.xlWorkbook Normal,null,null,false,false,Excel.XlSaveAsAccessM ode.xlShared,false,false,null,null);

                l1.Text = "File Created Successfully!!!";
            }
            catch(Exception Ex)
            {

                l1.Text = Ex.Message;
            }
}






Similar Threads
Thread Thread Starter Forum Replies Last Post
Building an Excel like Application yuenli C# 2005 1 June 22nd, 2007 11:57 AM
Excel Application dpkbahuguna Beginning VB 6 2 November 29th, 2006 06:49 AM
write multi-sheet Excel w/o Excel.Application manmoth Classic ASP Components 2 November 22nd, 2005 10:56 AM
Setting a new Excel application Shasur Pro VB 6 1 September 21st, 2005 10:12 AM
Excel.Application whiteshark Classic ASP Components 1 September 4th, 2003 06:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.