Free Support Forum - aspose.com

GridWeb will not import - ImportExcelFile

I have a simple page using a GridWeb control. The control may be empty allowing the user to create a sheet from scratch and save it. So far no problem. I also allow the user to upload a file that I first save and then use ImportExcelFile to load the GridWeb.

I have been able to use this latter technique with files that were created from scratch using the GridWeb, as well as a few others than I created from scratch using Excel 2003.

However several spreadsheets will not display. These I got from various sources. In fact the one attached that won't load was created using Cells with the following statement:

workbook.Save(filePath, new XlsSaveOptions(SaveFormat.Excel97To2003));

I get no errors; just nothing displayed.

I have attached 2 files. Their names indicate which one works and which one does not.

The GridWeb decalaration:

<acw:GridWeb ID="GridWeb1" runat="server" Height="400px" Width="1200px" PresetStyle="Colorful2"

ShowLoading="false" OnSaveCommand="GridWeb1_SaveCommand" EnableClientColumnOperations="true"

EnableClientMergeOperations="true" EnableClientResizeColumnRow="true" EnableClientRowOperations="true"

MaxColumn="50" MaxRow="500" ShowCommandBarAtTop="true" ShowContextMenu="true" OnCustomCommand="GridWeb1_CustomCommand"

ShowTabBar="false" EnablePaging="false" ShowSaveButton="false" ShowSubmitButton="false" ShowUndoButton="false">

<CustomCommandButtons>

<acw:CustomCommandButton ID="cmdSave" Text="Save" Command="cmdSave" ImageUrl="Images/24x24 save.png" ToolTip="Save and leave sheet open" Width="26px">

</acw:CustomCommandButton>

<acw:CustomCommandButton ID="cmdSave2" Text="Save" Command="cmdSave" ImageUrl="Images/spreadSave.png" ToolTip="Save and leave sheet open" Width="45px">

</acw:CustomCommandButton>

<acw:CustomCommandButton ID="cmdSaveClose" Text="Save & Close" Command="cmdSaveClose" ImageUrl="Images/24x24 file_apply.png" ToolTip="Save and close sheet" Width="26px">

</acw:CustomCommandButton>

<acw:CustomCommandButton ID="cmdSaveClose2" Text="Save & Close" Command="cmdSaveClose" ImageUrl="Images/spreadSaveClose.png" ToolTip="Save and close sheet" Width="92px">

</acw:CustomCommandButton>

<acw:CustomCommandButton ID="cmdClose" Text="Close" Command="cmdClose" ImageUrl="Images/24x24 file_cancel.png" ToolTip="Close sheet (unsaved changes will be lost)" Width="26px">

</acw:CustomCommandButton>

<acw:CustomCommandButton ID="cmdClose2" Text="Close" Command="cmdClose" ImageUrl="Images/spreadClose.png" ToolTip="Close sheet (unsaved changes will be lost)" Width="40px">

</acw:CustomCommandButton>

</CustomCommandButtons>

</acw:GridWeb>

The code behind that loads the GridWeb:

protected void loadSheet()

{

String docFileName = Session["currentWorksheetGUID"].ToString() + ".xls";

String docURL = Server.MapPath(@"~\Worksheets\") + docFileName;

if (File.Exists(docURL))

GridWeb1.WebWorksheets.ImportExcelFile(docURL);

}

Any ideas?

Thanks

Jim

Hi,


I tested loading your template file with GridWeb v2.7.5.2000 (latest version), it works fine. See the attached screen shot and here is my simplest code:

GridWeb1.WebWorksheets.Clear();
GridWeb1.WebWorksheets.ImportExcelFile(“e:\test2\GridWeb_Can_NOT_Open_This.xls”);

Please try our latest version of GridWeb, you may download the latest package of Aspose.Cells for .NET v7.2.0 and install its msi, and get the latest version of Aspose.Cells.GridWeb control:
http://www.aspose.com/community/files/51/.net-components/aspose.cells-for-.net/entry375305.aspx

Thank you.

Hi,

Thanks for your posting and using Aspose.Cells for GridWeb.

Please download and use the latest version:
Aspose.Cells
for GridWeb v2.7.5.2001

it will work fine.


I downloaded the latest dll’s as suggested, but still have the same problem.
Here’s what I found did work:

  1. Create a new workbook by using the technique I want to - upload an existing file and then import it into GridWeb - shows as empty
  2. Create a new file using GridWeb with a single cell populated and save
  3. Open the uploaded file (that GridWeb wouldn’t open) and copy its contents
  4. Paste and save the contents into the new file created in step 2
  5. Open the file that was just updated using GridWeb - It Works!

So, GridWeb was able to open the same content as the uploaded file, but only after it was copied into a file that GridWeb originally created.

Does this shed any light on the issue?

Thanks in advance

Jim

Hi,


Please create a sample project, zip it and post it here with all the files here, we will check your issue soon.

Thank you.

I got it working by including the GridWeb1.WebWorksheets.Clear(); statement that you identified earlier in this thread.

Thanks

Jim

Hi Jim,


That is great :slight_smile:

Feel free to contact us any time if you need further help or find any issue.

Thank you.

Hi Aspose Team,

could you please help me on this GridWeb, i have an single excel file with 10 sheets..i need to bind the single sheet (Say Sheet5) in GridWeb when importing the ImprotExcelFile method in page load...but 10 tabs sheet name should display below on the screen. when i click on each tab its should bind the data according to the sheets in the GridWeb.

Is this possible in this tool....Can u plase advice on this..?

Regards,

Gawaskar.

Hi Gawaskar,


Thanks for your inquiry.

I am afraid, I could not understand you completely what you require for.

But, one thing is sure, we follow MS Excel standards and in MS Excel, all the visible sheets are rendered when you open an Excel file into it. So, in GridWeb, if a worksheet is not hidden, its corresponding sheet’s tab will be there in the sheet tab bar. You may also hide the sheet tab bar and the sheet tabs will not be shown either for all the sheets (you may use GridWeb.ShowTabBar attribute).

By the way, you may activate a worksheet in the GridWeb by using WebWorksheets.ActiveSheet/ActiveSheetIndex property if can suit you.

Thank you