Login    Forum    Search    FAQ   Blog

Board index » Server Side Development » ASP 3.0




 Page 1 of 1 [ 8 posts ] 



Author Message
 Post subject: unable 2 read the date vals 4m the excel
 Post Posted: Sun Nov 22, 2009 2:33 pm 
Offline

Joined: Sat Feb 21, 2009 3:15 pm
Posts: 41
Hi,

I used the code given in da below link 2 read the data 4m the
excel file nd then show it on the gridview.

http://www.aspfree.com/c/a/ASP.NET-Code ... om-ASPNET/

The code runs fine hoeevr da 'date' values(format type is date) present in
the excel file were not at all read. Please suggest if have 2 do ne
additional changes.

Thank u in Advance


Top 
 Post subject: Re: unable 2 read the date vals 4m the excel
 Post Posted: Sun Nov 22, 2009 2:33 pm 
Offline

Joined: Sat Feb 21, 2009 11:06 am
Posts: 1794
Hello!!!! every one

Please Send ur Code.


Top 
 Post subject: Re: unable 2 read the date vals 4m the excel
 Post Posted: Sun Nov 22, 2009 2:34 pm 
Offline

Joined: Sat Feb 21, 2009 1:08 pm
Posts: 549
http://www.aspsnippets.com/post/2009/06 ... ntrol.aspx


Top 
 Post subject: Re: unable 2 read the date vals 4m the excel
 Post Posted: Sun Nov 22, 2009 2:34 pm 
Offline

Joined: Sat Feb 21, 2009 3:15 pm
Posts: 41
my code was just as below:

Code:
string filename = @"c:\\202673.xls";
        OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filename + ";Extended Properties=Excel 8.0");
        con.Open();
        try
        {
            //Create Dataset and fill with imformation from the Excel Spreadsheet for easier reference
            DataSet myDataSet = new DataSet();
            OleDbDataAdapter myCommand = new OleDbDataAdapter(" SELECT * FROM [grpcrd.cr\\$\\]", con);
            myCommand.Fill(myDataSet);
            con.Close();
            Response.Write("\nDataSet Filled");
            GridView1.DataSource = myDataSet.Tables[0];
            GridView1.DataBind();
            //Travers through each row in the dataset
            foreach (DataRow myDataRow in myDataSet.Tables[0].Rows)
            {
                //Stores info in Datarow into an array
                Object[] cells = myDataRow.ItemArray;
                //Traverse through each array and put into object cellContent as type Object
                //Using Object as for some reason the Dataset reads some blank value which
                //causes a hissy fit when trying to read. By using object I can convert to
                //String at a later point.
                foreach (object cellContent in cells)
                {
                    //Convert object cellContect into String to read whilst replacing Line Breaks with a defined character
                    //string cellText = cellContent.ToString();
                    //        cellText = cellText.Replace("\n", "|");
                    //Read the string and put into Array of characters chars
                    Response.Write("\n" + cellContent.ToString());
                }
                Response.Write("<br />");
            }
            Thread.Sleep(15000);
        }
        catch (Exception ex)
        {
            throw(ex);
            //Thread.Sleep(15000);
        }
        finally
        {
            con.Close();
        }



Top 
 Post subject: Re: unable 2 read the date vals 4m the excel
 Post Posted: Sun Nov 22, 2009 2:34 pm 
Offline

Joined: Sat Feb 21, 2009 3:15 pm
Posts: 41
I usd "IMEX=1" in da connection string nd the issue was resolved.

Source: http://social.msdn.microsoft.com/forums ... 487db0a2c/


Top 
 Post subject: Re: unable 2 read the date vals 4m the excel
 Post Posted: Sun Nov 22, 2009 2:35 pm 
Offline

Joined: Sat Feb 21, 2009 11:06 am
Posts: 1794
Hi,

Using OleDb 4 readin the Excel files could be problematic, especially
formattin nd data types could cause troubles.

You must check out GemBox.Spreadsheet .NET Excel componen 4 reading nd then
writin XLS, XLSX, ODS, CSV and HTML files.

Free version does have sum kinda restrictions, howevr you could
use it freely in free commercial apps.

Here is a web demo how 2 export DataTable 2 Excel file thro ASP.NET
stream using GemBox.Spreadsheet.


Top 
 Post subject: Re: unable 2 read the date vals 4m the excel
 Post Posted: Sun Nov 22, 2009 2:38 pm 
Offline

Joined: Sat Feb 21, 2009 3:15 pm
Posts: 41
........


Top 
 Post subject: Re: unable 2 read the date vals 4m the excel
 Post Posted: Sun Nov 22, 2009 2:39 pm 
Offline

Joined: Sat Feb 21, 2009 3:16 pm
Posts: 46
Hi ,

Since you r workin wid the C# then Use SQUARE BRACKETS [] wen settin
indexers instead f Parenthesis ().. You could follow da codes providd
above to fix ur problem


Top 
Display posts from previous:  Sort by  
 
 Page 1 of 1 [ 8 posts ] 




Board index » Server Side Development » ASP 3.0


Who is online

Users browsing this forum: No registered users and 2 guests

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron