Read data from excel in asp.net

I want to read a whole excel sheet's data in a single textbox.

Is this possible?

I know the code to read a cell's data from excel to a textbox.

PrivateSub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click

    Dim xlaTest As Excel.Application = CType(CreateObject("Excel.Application"), Excel.Application)
    xlaTest.Visible = True
    Dim wbkTest As Excel.Workbook = xlaTest.Workbooks.Open("D:\Tests\VBTrials\ExcelTests\TestWorkbook.xls")
    Dim wshTest As Excel.Worksheet = DirectCast(wbkTest.Worksheets("Sheet1"), Excel.Worksheet)
    TextBox1.Text = wshTest.Range("B2").Value
    wbkTest.Close()
    xlaTest.Quit()

EndSub

Answers


private List<object> Excelvoider()
        {
            Excel.Application xlApp = new Excel.Application();
            Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(@"C:/Temp/Книга1.xlsx");
            Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1];
            Excel.Range xlRange = xlWorksheet.Range["B3", "Q58"];
            List<object> stroke = new List<object>();
            int rowCount = xlRange.Rows.Count;
            int colCount = xlRange.Columns.Count;
            for (int i = 1; i <= rowCount; i++)
            {
                for (int j = 1; j <= colCount; i++)
                {
                      stroke.Add(xlRange.Value2[i, j]);
                }
            }
            return stroke;
        }

This is Range from one cell to another:

Excel.Range xlRange = xlWorksheet.Range["B3", "Q58"];

You also can use xlWorksheet.UsedRange.


Need Your Help

Is it ok to re-sort an array each time you need to access an element at a specific index?

objective-c sorting core-data ios nsarray

I have a TableViewController that displays a list of elements CoreData relationship. In my cellForRowAtIndexPath:, I am getting a sortedArray from the set and then accessing the element at indexPat...

Obtaining a specific document ID from sharepoint using web services in c#

c# web-services sharepoint

I have an external sharepoint site, where I need to update the metadata of a large set of files. The best way to do this seems to be using the Lists web service, and using the Lists.UpdateListItems