Import Microsoft Excel File

Import Excel Files

Import from File

To open an Excel file using Aspose.Cells.GridWeb control:

  1. Add the Aspose.Cells.GridWeb control to a web form.
  2. Import the Excel file by specifying the file path.
  3. Run the application.

When Aspose.Cells.GridWeb control is added to a web form, the control is automatically instantiated and added to the form with a default size. You don’t have to create an Aspose.Cells.GridWeb control object. All you have to do is drag and drop the control and start using it.

However, to load the content from an Excel file into Aspose.Cells.GridWeb control, you have to call the ImportExcelFile method to specify the path of the Excel file. After that, Aspose.Cells.GridWeb control will automatically find the file from the specified path and display its contents. A code snippet that loads the contents of an Excel file is provided below.

The above code snippet can be used in any way you want. For example, to load an Excel file automatically when a web form loads, add this code to the form’s Page_Load event. If you want to open a file when a button is clicked, add a button to the web form and write the above code under the button’s Click event.

An Excel file is loaded when a button is clicked

todo:image_alt_text

Import from Stream

As well as opening Excel files from a file, the Aspose.Cells.GridWeb control can load Excel files from a stream. Using a file as a stream is a better approach to avoid any file‑access or sharing‑violation problems because this approach ensures that all connections to the files are closed by closing the stream.