Im trying to use the reportviewer
provided by Visual Studio (windows form application) to create a report based on an excel spreadsheet. However I am struggling to find the correct way to read/access the spreadsheet.
When I try to create a new report I get the following window:
I've tried to use the object option but havent had any luck
Question: How would I use an excel spreadsheet to create a report?
I had some luck with the following code which allowed me to process the file, but I cant find a way to tie it into the reportviewer:
Excel.Application ExcelObj = new Excel.Application();
this.openFileDialog1.FileName = "*.xls";
if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
{
Excel.Workbook theWorkbook = ExcelObj.Workbooks.Open(
openFileDialog1.FileName, 0, true, 5,
"", "", true, Excel.XlPlatform.xlWindows, "\t", false, false,
0, true);
Excel.Sheets sheets = theWorkbook.Worksheets;
Excel.Worksheet worksheet = (Excel.Worksheet)sheets.get_Item(1);
for (int i = 1; i <= 10; i++)
{
Excel.Range range = worksheet.get_Range("A" + i.ToString(), "J" + i.ToString());
System.Array myvalues = (System.Array)range.Cells.Value;
string[] strArray = ConvertToStringArray(myvalues);
}
}
Any advice/guidance is welcome