need help with reading Excel file

Chaospratan

New Member
Ok, I'm using the following code to display an Excel spreadsheet in a dataGrid:<BR><BR><script language="C#" runat="server"><BR>protected void Page_Load(Object Src, EventArgs E)<BR>{<BR>string strConn;<BR>strConn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Webs\myfiles\www\dotnet\bids.xls;Extende d Properties=Excel 8.0;";<BR>//You must use the $ after the object you reference in the spreadsheet<BR>OleDbDataAdapter myCommand=new OleDbDataAdapter("SELECT * FROM [sheet1$]", strConn);<BR><BR>DataSet myDataSet = new DataSet();<BR>myCommand.Fill(myDataSet, "ExcelInfo");<BR>DataGrid1.DataSource = myDataSet.Tables["ExcelInfo"].DefaultView;<BR>DataGrid1.DataBind();<BR>}<BR></script><BR><BR>It works nicely and everything, however, on the actual Excel spreadsheet, there are a bunch of monetary values, with dollar signs, commas, and periods where applicable --- in other words, the numbers are shown as currency. However, on the resulting datagrid, they are just shown as numbers, not formatted as currency. Is there anything I could, or should do to get the web page to show the number values as money values?
 
Back
Top