I have an excelworkbook the user has saved to the server.
I have a radgrid that is being databound to this excel workbook.
This workbook can have varying number of columns so I cannot hardcode the columns
Each column will have various datatypes in them.. For example
Column 1 will be mixed alphanumeric values
Column 2 will be dates
Column 3 will be mixed alphanumerics
When I bind the excelworkbook to the radgrid all of the alpha numeric columns (Letters and numbers) do not show up..
ANy idea on how to fix this issue?
I am using the following code plex project to translate the excel workbook into a dataset with tables for each tab in the excel workbook:
http://exceldatareader.codeplex.com/
The code that actual binds the radgrid:
I have a radgrid that is being databound to this excel workbook.
This workbook can have varying number of columns so I cannot hardcode the columns
Each column will have various datatypes in them.. For example
Column 1 will be mixed alphanumeric values
Column 2 will be dates
Column 3 will be mixed alphanumerics
When I bind the excelworkbook to the radgrid all of the alpha numeric columns (Letters and numbers) do not show up..
ANy idea on how to fix this issue?
I am using the following code plex project to translate the excel workbook into a dataset with tables for each tab in the excel workbook:
http://exceldatareader.codeplex.com/
The code that actual binds the radgrid:
protected DataSet Data { get { if (Application["data"] == null) { return null; } return Application["data"] as DataSet; } }private void ImportFromExcel() { // Bind Data and populate Dropdown string filePath = String.Format("~/ImportProduction/{0}", FileName); FileStream stream = File.Open(Server.MapPath(filePath), FileMode.Open, FileAccess.Read); IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream); excelReader.IsFirstRowAsColumnNames = firstRowIsHeaderRowCheckBox.Checked; Application["data"] = excelReader.AsDataSet(); excelReader.Close(); foreach (DataTable t in Data.Tables) { var name = t.TableName; var index = Data.Tables.IndexOf(t); RadComboBoxItem item = new RadComboBoxItem(name, index.ToString()); RadComboBox1.Items.Add(item); }
RadGridImport.Rebind(); }protected void RadGridImport_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e) { if (Data != null) { var selectedWorkSheet = RadComboBox1.SelectedIndex; if (selectedWorkSheet != -1) (sender as RadGrid).DataSource = Data.Tables[selectedWorkSheet]; ValidateButton.Enabled = true; } }