Shapes are not loaded after loading excel file when using Aspose.Cell.Gridweb

AsposeQuestion.jpg (327.9 KB)

Hello;

I have some shapes in my excel file and I would like to load to web page this excel file with Aspose.Cell.Gridweb. if I use original Aspose example there is not any problem. I can see all shapes in spreadsheld from excel. but if I use my created program shapes are not loaded and I see updating.gif (blue circle) instead of original shapes in excel. You can see on the picture my problem.

Could you help me for solving this problem?

@caglayan.altay,

Thanks for the screenshot.

Which version of Aspose.Cells.GridWeb you are using (.NET/Java)? In which Aspose example, it works fine? Please try using latest version/fix: Aspose.Cells.GridWeb v22.9 with latest resource files (acw_client folder) in your project. If you still find any issue, kindly do share your template Excel file containing the shapes, we will check it soon.

PS. please zip the Excel file prior attaching.

@Amjad_Sahi;

Thank you very much for your reply;

I’m using .net. Visual Studio 2019. I added nuget package, It’s last version (22.9).
I upload fine working project and Not working project. I would like to modify not working project.

I saw a difference and I upload it.<a class=“attachment”
2707415707.zip (159.4 KB)
WorkingProject.zip (8.5 MB)
GridWeb.Net4 (Sample from Aspose).zip (6.7 MB)

Not working project is in this link

https://cengizmakina-my.sharepoint.com/:f:/g/personal/caltay_cengizmakina_com_tr/EnVadlz0ryxOkTVaQCIuzI4B91o9cZfS1VKC8UNkZ_fTfw?e=aF6RTO

@caglayan.altay,

Thanks for the samples.

I tried to download not working project using your link but it navigates me to a page where I have to provide credentials. In short, I could not download attachments from your link. Could you please provide a shared link to download your external attachment(s) (Not working project) seamlessly without giving id or password. We will check your issue soon.

@Amjad_Sahi;

Thank you for your reply;

I uploaded not working project to google drive. Thank you your help.

https://drive.google.com/drive/folders/1HOMT-9nQpq0hDMGKXzgSS0KKhAAs8LOH?usp=sharing

@caglayan.altay,

Thanks for download link for the sample project.

Please notice, after an initial test, I am able to reproduce the issue as you mentioned by using your template file and sample application. I found shapes are not loaded properly into the matrix after loading the Excel file when using Aspose.Cell.GridWeb with Ajax mode. I have logged a ticket with an id “CELLSNET-52117” for your issue. We will look into your issue soon.

Once we figure it out our have some other updates on it, we will let you know.

@caglayan.altay
as per my investigation.
all the image url request is blocked with a 404 from server.
for example:
the below request
https://localhost:44389/OpenExcelDirect/acw_image/0_0_0_0.5a1f6d79-2533-4eca-a950-27be8c62b8f6?638010830833826875
got the error as:
IIS 10.0 Detailed Error - 404.0 - Not Found
So the problem is the route config

finally, this the workaround for your solution:

public class MyWebFormsFriendlyUrlResolver : WebFormsFriendlyUrlResolver
{
public MyWebFormsFriendlyUrlResolver() { }

    public override string ConvertToFriendlyUrl(string path)
    {
        if (!string.IsNullOrEmpty(path))
        {
            if (path.ToLower().Contains("open"))
            { // Here the filter code
                return path;
            }
        }
        return base.ConvertToFriendlyUrl(path);
    }
}
public static class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        var settings = new FriendlyUrlSettings();
        settings.AutoRedirectMode = RedirectMode.Permanent;
        routes.EnableFriendlyUrls(settings, new IFriendlyUrlResolver[] {
                             new MyWebFormsFriendlyUrlResolver() });
    }
}

after filter out the OpenExcelDirect.aspx
the image request can be catched by the web control as normal

@peter.zhou,

Thank you very much for your reply;

Sorry I couldnt understand. How should I implement your codes to my current code.

My current code is below.

using Microsoft.AspNet.FriendlyUrls;
using Microsoft.AspNet.FriendlyUrls.Resolvers;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Routing;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebAppMachineDocuments
{
public partial class OpenExcelDirect : System.Web.UI.Page
{
string constr = ConfigurationManager.ConnectionStrings[“ConString”].ConnectionString;
string Machine_name, Part, Part_Name, Part_No, Part_Customer;
string UpdateId = “”;

    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie machineInfo = new HttpCookie("machineInfo");
        HttpCookie reqCookies = Request.Cookies["machineInfo"];

        if (Request.QueryString["MachineName"] != null)
        {
            Machine_name = Request.QueryString["MachineName"];                
            machineInfo["MachineName"] = Machine_name;
            Response.Cookies.Add(machineInfo);
        }
        else
        {
            Machine_name = reqCookies["MachineName"].ToString();
        }

        if (Request.QueryString["Part"] != null)
        {
            Part = Request.QueryString["Part"];
            machineInfo["Part"] = Part;
            Response.Cookies.Add(machineInfo);
        }
        else
        {
            Part = reqCookies["Part"].ToString();
        }

            string[] PartData = Part.Split('_');
            Part_Customer = PartData[0];
            Part_Name = PartData[1];
            Part_No = PartData[2] + "_" + PartData[3];


        if (!IsPostBack)
        {
            LoadData();
        }
       
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        SaveData();
    }

    private void LoadData()
    {
        //string fileName = "C:\\Excel\\2707415707.xls";

        //  string fileName = "C:\\Excel\\imalatOnayFormları\\"+Part_Customer+"\\"+ Part_Name + "\\"+ Part_No + ".xls";

        string fileName = CheckFile(); 

        // Imports from an excel file.
        GridWeb1.ImportExcelFile(fileName);
        // ExEnd:LoadExcelFile
    }

    private void SaveData()
    {
        // Generates a temporary file name.

        string path = "C:\\Excel\\DoluFormlar\\";
        string Vardiya ="";

        if (DateTime.Now.Hour < 8)
        {
            Vardiya = "1";
        }
        else if (DateTime.Now.Hour < 16)
        {
            Vardiya = "2";
        }
        else
        {
            Vardiya = "3";
        }   
        
        string filename = DateTime.Now.ToString("dd.MM.yyyy") +"_("+Vardiya+")_"+Machine_name+"_"+ Part + ".xls";    

        try
        {
            // Saves to the file.
            this.GridWeb1.SaveToExcelFile(path + filename);

            ShowMessage("Dosya Başarı ile Kaydedildi");
        }
        catch
        {
            ShowMessage("Dosya Kaydedilemedi!!!");

        }
    }

    // Handles the load file button click event and load an excel file from disk
    protected void btnLoadExcelFile_Click(object sender, EventArgs e)
    {
        LoadData();
    }

    protected void GridWeb1_SaveCommand(object sender, EventArgs e)
    {
        //// ExStart:SaveExcelFile
        //// Generates a temporary file name.
        //string filename = Session.SessionID + "_out.xls";


        ////string path =  "C:Excel\\";
        //string path = "C:\\PlcEkran\\Yazılım Geliştirme Projeleri\\WebAppOpenExcel\\Excel\\";

        //// Saves to the file.
        //this.GridWeb1.SaveToExcelFile(path + filename);

        //// Sents the file to browser.
        //Response.ContentType = "application/vnd.ms-excel";
        //Response.AddHeader("content-disposition", "attachment; filename=" + filename);
        //Response.WriteFile(path + filename);
        //Response.End();
        //// ExEnd:SaveExcelFile
    }

    private Boolean CheckShiftRecord(string machine)
    {

        string query = "SELECT * FROM OnayRaporu where Machine='" + machine + "'";

        if (DateTime.Now.Hour < 8)
        {
            query = query + " and Date between '" + DateTime.Now.ToString("dd.MM.yyyy") + " 00:00:00' and '" + DateTime.Now.ToString("dd.MM.yyyy") + " 08:00:00' ";
        }
        else if (DateTime.Now.Hour < 16)
        {
            query = query + " and Date between '" + DateTime.Now.ToString("dd.MM.yyyy") + " 08:00:00' and '" + DateTime.Now.ToString("dd.MM.yyyy") + " 16:00:00' ";
        }
        else
        {
            query = query + " and Date between '" + DateTime.Now.ToString("dd.MM.yyyy") + " 16:00:00' and '" + DateTime.Now.ToString("dd.MM.yyyy") + " 23:59:59' ";
        }


        using (SqlConnection con = new SqlConnection(constr))
        {
            using (SqlDataAdapter sda = new SqlDataAdapter(query, con))
            {
                using (DataTable dt = new DataTable())
                {
                    sda.Fill(dt);

                    if (dt.Rows.Count > 0)
                    {
                        UpdateId = dt.Rows[0]["Id"].ToString();
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
        }
    }

    protected void ShowMessage(string data)
    {
        ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + data + "');", true);
    }

    private String CheckFile()
    {
        string path = "C:\\Excel\\DoluFormlar\\";
        string Vardiya = "";

        if (DateTime.Now.Hour < 8)
        {
            Vardiya = "1";
        }
        else if (DateTime.Now.Hour < 16)
        {
            Vardiya = "2";
        }
        else
        {
            Vardiya = "3";
        }

        string filename = DateTime.Now.ToString("dd.MM.yyyy") + "_(" + Vardiya + ")_" + Machine_name + "_" + Part + ".xls";

        if (File.Exists(path+filename))
        {
            return "C:\\Excel\\DoluFormlar\\" + DateTime.Now.ToString("dd.MM.yyyy") + "_(" + Vardiya + ")_" + Machine_name + "_" + Part + ".xls";
        }
        else
        {
            return  "C:\\Excel\\imalatOnayFormları\\" + Part_Customer + "\\" + Part_Name + "\\" + Part_No + ".xls";
        }

    }

 
}  

}

@caglayan.altay,

We will get back to you soon to provide relevant details for your reference.

@caglayan.altay
Please just update WebAppExcelExample\App_Start\RouteConfig.cs
to the code I updated.

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Routing;
using Microsoft.AspNet.FriendlyUrls;
using Microsoft.AspNet.FriendlyUrls.Resolvers;

namespace WebAppExcelExample
{
public class MyWebFormsFriendlyUrlResolver : WebFormsFriendlyUrlResolver
{
public MyWebFormsFriendlyUrlResolver() { }

    public override string ConvertToFriendlyUrl(string path)
    {
        if (!string.IsNullOrEmpty(path))
        {
            if (path.ToLower().Contains("open"))
            { // Here the filter code
                return path;
            }
        }
        return base.ConvertToFriendlyUrl(path);
    }
}
public static class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        var settings = new FriendlyUrlSettings();
        settings.AutoRedirectMode = RedirectMode.Permanent;
        routes.EnableFriendlyUrls(settings, new IFriendlyUrlResolver[] {
                             new MyWebFormsFriendlyUrlResolver() });
    }
}

}

Hello @peter.zhou;

Thank you very much for your help. Problem not solved for me. I upload changed program and secreen shuts. Where I made false I couldn’t find. If its possible could you help me?

Result.jpg (317.9 KB)

https://drive.google.com/drive/folders/1HOMT-9nQpq0hDMGKXzgSS0KKhAAs8LOH?usp=sharing

@caglayan.altay
here is the project
WebAppExcelExample.zip (1.0 MB)

Helleo @peter.zhou,

Thank you new download, I think you deleted packages folder for small zip file.
I used Aspose.Cells.Gridweb.dll before, but now there is a new dll (GridWeb.dll) in the project.(see picture). But dll is not in zip file. Could you send me additionaly new GridWeb dll?

Missing dll file.jpg (52.6 KB)

@caglayan.altay
It doesnot matter.
the one you used is ok .
or you can use the latest version of Aspose.Cells.Gridweb.dll
just get from nupkg