473,394 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Default Displaying Excel In A Datagrid Issue

I am trying to display an excel spreadsheet on a page using datagrid, but for some reason it is filtering out some of the cells, leaving a blank space instead. Also, the "$" sign won't show up in most of the columns.Could someone please take a look at my site and file, and give a suggestion as to why this would be happening? I've tried a bunch of troubleshooting on it, with no success.


Web Page (Not all excel cells load):
http://www.toddrawson.com/excel_aspnet/index6.aspx

Excel File:
http://www.toddrawson.com/excel_aspn...egalTender.xls

Code For Datagrid:
Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="VB" %>
  2. <%@ Import Namespace="System.Data" %>
  3. <%@ Import Namespace="System.Data.Oledb" %>
  4.  
  5. <script language="VB" runat="server">
  6. Sub Page_Load(sender As Object, e As EventArgs)
  7. Dim objDataSet As New DataSet()
  8.  
  9. Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  10. "Data Source=" & Server.MapPath(".") & "\2DLegalTender.xls;" & _
  11. "Extended Properties=""Excel 8.0;"""
  12.  
  13.  
  14. Dim objDataAdapter As New OledbDataAdapter("SELECT * FROM [Sheet1$]", strConn)
  15.  
  16. objDataAdapter.Fill(objDataSet)
  17.  
  18. DataGrid1.DataSource = objDataSet.Tables(0).DefaultView
  19. DataGrid1.DataBind()
  20. End Sub
  21. </script>
  22.  
  23.       <p><asp:Label id=Label1 runat="server"><B></B></asp:Label></p>
  24. <asp:datagrid id="DataGrid1" runat="server" 
  25. borderstyle="Ridge"
  26. borderwidth="2px" 
  27. cellpadding="3"
  28. cellspacing="1" 
  29. bordercolor="White" 
  30. backcolor="White"
  31. gridlines="None">
  32. <selecteditemstyle font-bold="True" forecolor="White"
  33. backcolor="#9471DE">
  34. </selecteditemstyle>
  35. <itemstyle borderwidth="1px" 
  36. forecolor="Black"
  37. borderstyle="Solid" 
  38. bordercolor="#FF8000" 
  39. backcolor="#DEDFDE">
  40. </itemstyle>
  41. <headerstyle font-bold="True" borderwidth="1px"
  42. forecolor="#E7E7FF" borderstyle="Double" bordercolor="DarkSlateBlue"
  43. backcolor="#4A3C8C"></headerstyle>
  44. <footerstyle forecolor="Black"
  45. backcolor="#C6C3C6"></footerstyle>
  46. <pagerstyle horizontalalign="Right" forecolor="Black"
  47. backcolor="#C6C3C6"></pagerstyle>
  48.  
  49. </asp:datagrid></p>
  50.  
Feb 12 '10 #1
1 1310
CroCrew
564 Expert 512MB
Hello picassosson,

Give this a try:

Change your data grid to this:
Expand|Select|Wrap|Line Numbers
  1. <asp:datagrid id="DataGrid1" runat="server" AutoGenerateColumns="False" >
  2.     <Columns>
  3.         <asp:BoundColumn DataField="F1" HeaderText="Field 1" />
  4.         <asp:BoundColumn DataField="F2" HeaderText="Field 2" DataFormatString="{0:c}" />
  5.         <asp:BoundColumn DataField="F3" HeaderText="Field 3" />
  6.         <asp:BoundColumn DataField="F4" HeaderText="Field 4" />
  7.         <asp:BoundColumn DataField="F5" HeaderText="Field 5" />
  8.         <asp:BoundColumn DataField="F6" HeaderText="Field 6" />
  9.         <asp:BoundColumn DataField="F7" HeaderText="Field 7" DataFormatString="{0:c}" />
  10.     </Columns>
  11. </asp:datagrid>
  12.  
Then change your on load event to this:
Expand|Select|Wrap|Line Numbers
  1. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  2.     Dim objDataSet As New DataSet()
  3.     Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("Includes") & "\2DLegalTender.xls;Extended Properties='Excel 8.0; HDR=No; IMEX=1'"
  4.     Dim objDataAdapter As New OleDbDataAdapter("SELECT * FROM [Sheet1$]", strConn)
  5.  
  6.     objDataAdapter.Fill(objDataSet)
  7.  
  8.     DataGrid1.DataSource = objDataSet.Tables(0)
  9.     DataGrid1.DataBind()
  10. End Sub
  11.  
Happy Coding,
CroCrew~
Feb 17 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Diego TERCERO | last post by:
Hi... I'm working on a tool for editing text resources for a family of software product my company produces. These text resources are found in a SQL Server database, in a table called...
2
by: Steve Chatham | last post by:
I use the following code: Private Sub RbtnExport_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RbtnExport.SelectedIndexChanged Dim sFile As String =...
1
by: RSB | last post by:
Hi Everyone, i am using the following code to transfer a DataGrid to Excel File. Every thing works ok beside the long numerice value like 0000121900000000 gets converted to 1.219E+11. how can i...
0
by: optimizeit | last post by:
What I am attempting to do is import an Excel Workbook and display the worksheets in a datagrid dynamically. I am very close to getting this to work. I have to this point successfully imported a...
2
by: Arvind R | last post by:
Hello, how to ask saveas dialog before writing the data to the excel file? right now im able to save in c drive or any other specified location only. any solution will be a great help! ...
4
by: Frank | last post by:
Hello All, I ham using VS.NET 2003. Have followed instructions from http://gridviewguy.com/ArticleDetails.aspx?articleID=26 along with several other articles to no avail. I am pulling my hair...
2
by: Kenny M. | last post by:
Hi I'm using the code shown here to export only my DataGrid to Excel. http://www.c-sharpcorner.com/Code/2003/Sept/ExportASPNetDataGridToExcel.asp In my page I have two DropDownListBox, two...
13
by: Hemant Sipahimalani | last post by:
The following piece of code is being used to export HTML to excel. HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"...
5
by: =?Utf-8?B?U3R1YXJ0?= | last post by:
Hi There I have been having a play around with the following code to display a datagrid in Excel (all from Steve Orr's site): Private Sub btnTechServAccred_Click(ByVal sender As System.Object,...
2
by: leena13 | last post by:
Hi, The number of rows in the datagrid on my page are approx. around 14130. When I click on the button that exports the records to excel sheet, the page goes blank (I observed that none of the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.