ExternalLinks XLSX

Last post 06-16-2010, 1:59 AM by aspose.notifier. 18 replies.
Page 1 of 2 (19 items)   1 2 Next >
Sort Posts: Previous Next
  •  05-21-2010, 9:31 AM 239318

    ExternalLinks XLSX .NET

    Hi

    There appears to be an issue with ExternalLinks from Excel 2007 files. It works as expected with Excel 2003, reading Excel 2007(xlsx) files however ExternalLinks always is always empty. Would greatly appreciate if someone could take a look into this. Using release 4.9.1.0

    Code is simply

    Workbook workbook = new Workbook();
    workbook.Open(@"C:\HelloWorld.xlsx");
    ExternalLinks references = workbook.Worksheets.ExternalLinks;

    Thanks
    Kevin



    Kevin Logue
    Software Technology Research Centre
    Dundalk Institute of Technology
     
  •  05-21-2010, 10:02 AM 239325 in reply to 239318

    Re: ExternalLinks XLSX

    Hi,

    Please use Worksheet.Hyperlinks instead for your requirement. It will give you all types of hyperlinks whether they are external or internal.

    e.g

    Workbook workbook = new Workbook();
                workbook.Open("e:\\test\\Book1.xlsx");
               
               //Get the hyperlinks from the first worksheet.
                Hyperlinks hlinks = workbook.Worksheets[0].Hyperlinks;
                MessageBox.Show(hlinks.Count.ToString());
                MessageBox.Show(hlinks[0].Address);

    //................



    Thank you.



    Amjad Sahi
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  05-21-2010, 10:32 AM 239333 in reply to 239325

    Re: ExternalLinks XLSX

    I'm not sure we're talking about the same thing. An external reference is a reference to an external spreadsheet eg. ='C:\SomeFolder\[HelloWorlsd.xls]Sheet1'!$A$1 would allow me to use/show the value from A1 Sheet1 HelloWorld.xls in another spreadsheet. A hyperlink on the other hand would just open up the linked file/url , assuming Aspose follows the same naming convention of Excel.

    Regardless I've tested the above code and it doesn't pick up references to other spreadsheets (Which I wouldn't expect it too).

    Kevin Logue
    Software Technology Research Centre
    Dundalk Institute of Technology
     
  •  05-21-2010, 12:58 PM 239366 in reply to 239333

    Re: ExternalLinks XLSX

    Hi,

    Sorry for the confusion.

    Please use Workbook.HasExternalLinks() method to check whether a workbook has some external references. Also, you may use Cell.ContainsExternalLink boolean attribute to check if a cell has external link reference in the formula. See the sample code below:

                Workbook workbook = new Workbook();
                workbook.Open("e:\\test\\ExtBook2.xlsx");
                bool checklinks = workbook.HasExernalLinks();
                MessageBox.Show("External Links: " + checklinks.ToString());

                //Get the first worksheet.
                Worksheet worksheet = workbook.Worksheets[0];

               // workbook.CalculateFormula();

                int cnt = 0;
                for (int i = 0; i <= worksheet.Cells.MaxDataRow; i++)
                {
                    for (int j = 0; j <= worksheet.Cells.MaxDataColumn; j++)
                    {
                        if (worksheet.Cells[i,j].ContainsExternalLink)
                        {
                            cnt++;
                            MessageBox.Show(worksheet.Cells[i,j].Name);
                            MessageBox.Show(worksheet.Cells[i,j].Formula);
                            MessageBox.Show(worksheet.Cells[i, j].StringValue);

                        }
                    }
               
                }

                MessageBox.Show("total external links in sheet1: " + cnt);

               
               

    Thank you.


    Amjad Sahi
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  05-21-2010, 4:01 PM 239407 in reply to 239366

    Re: ExternalLinks XLSX

    Hi, thanks for the reply. I won't be in the office till Monday and don't have access to our Aspose license to test this, I'd have major concerns regarding performance with this approach, especially in extremely large spreadsheets. I've seen slow down already when working through a large cell range using MaxDataRow and MaxDataColumn (which is understandable). Are there no intentions to fix the ExternalLinks property for xlsx workbooks?


    Kevin Logue
    Software Technology Research Centre
    Dundalk Institute of Technology
     
  •  05-22-2010, 1:54 AM 239424 in reply to 239407

    Re: ExternalLinks XLSX

    Hi,

    I have logged your request into our issue tracking system with an id: CELLSNET-17060. We will analyze/investigate if we can enhance the ExternalLinks API for XLSX files.

    We will get back to you soon.

    Thank you.

    Amjad Sahi
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  05-22-2010, 9:29 AM 239442 in reply to 239424

    Re: ExternalLinks XLSX

    Thanks, in the mean time the workaround I've been using is below, in case anyone else has run into this issue...

    Workbook wb = new Workbook();
    wb.Open(@"C:\Test\LinkTest.xlsx");
    int counter = 0;

    if (wb.HasExernalLinks())
    {
        foreach (Worksheet worksheet in wb.Worksheets)
        {
            Cell linkCell = null;
            do
            {
                // Within an ExternalLink the spreadsheet named is wrapped around [spreadsheetname.xlsx]
                // I'm not aware of another valid use of [] within an Excel formula
                linkCell = worksheet.Cells.FindFormulaContains("[", linkCell);
                if (linkCell != null)
                {
                    if (linkCell.ContainsExternalLink)
                    {
                        counter++;
                    }
                }
            } while (linkCell != null);
        }
    }

    It offers reasonable performance (~10 seconds on a sheet with 2, 525, 202 cells though this was on a fairly beefy system). I haven't had a chance to profile it properly against manually iterating through the MaxDataRow and MaxDataColumn, though this assumes FindFormulaContains gives better performance (which I believe it does).

    The code needs to be tested more but should offer some assistance to people with this issue. It works on assumption that a formula with an ExternalLink will contain a square bracket (which it must), this alone is not sufficient as it can return some false positives so we still need to verify using the ContainsExternalLink property.


    Kevin Logue
    Software Technology Research Centre
    Dundalk Institute of Technology
     
  •  05-24-2010, 4:26 AM 239512 in reply to 239318

    Re: ExternalLinks XLSX

    Hi again, now I've got a strange bug. When I use the Formula property for a cell that contains a link in a XLSX file, the formula returns 

    "=SUM([1]Sheet1!$A$2:$A$6)" 

    It should be

    "=SUM('[Range1.xlsx]Sheet1'!$A$2:$A$6)"

    I'd hazard a guess that this is something to do with why your ExternalLinks property always returns an ExternalLinks of count 0 for XLSX. I can see the the correct value in the non public porperities for the cell but sadly can't access it.

    Would appreciate a fix as soon as possible

    Thanks

    Kevin Logue
    Software Technology Research Centre
    Dundalk Institute of Technology
     
  •  05-24-2010, 6:11 AM 239532 in reply to 239512

    Re: ExternalLinks XLSX

    It'd be great if I could get some idea if this intended or is indeed a bug as it's a blocker for us.

    Thanks


    Kevin Logue
    Software Technology Research Centre
    Dundalk Institute of Technology
     
  •  05-24-2010, 7:02 AM 239536 in reply to 239532

    Re: ExternalLinks XLSX

    Hi,

    We will get back to you soon.

    Thank you.

    Amjad Sahi
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  05-25-2010, 2:01 AM 239699 in reply to 239536

    Re: ExternalLinks XLSX

    Attachment: Present (inaccessible)
    Hi,

    Please try the attached version.We have supported ExternalLinks property for xlsx workbooks. You may use Worksheets.ExternalLinks attribute and Aspose.Cells.ExternalLink API.
     

    Thank you

    Amjad Sahi
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  05-25-2010, 3:10 AM 239715 in reply to 239699

    Re: ExternalLinks XLSX

    While the fix addresses the issue with ExternalLinks, Formula still returns the incorrect formula value in xlsx.


    Kevin Logue
    Software Technology Research Centre
    Dundalk Institute of Technology
     
  •  05-25-2010, 3:42 AM 239723 in reply to 239715

    Re: ExternalLinks XLSX

    Hi,

    Yes, the formula (the formulas having external links/references) issue is not resolved yet. We will fix it and let you know about it soon.

    Thank you.

    Amjad Sahi
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  05-25-2010, 3:56 AM 239730 in reply to 239723

    Re: ExternalLinks XLSX

    I've also noticed that the Datasource is now different between the XLS and XLSX APIs. In the XLS version the datasource is only the spreadsheet name with extension, whereas the datasource for XLSX also contains a pseudo file path (minus the drive letter)

    So in XLS we get

    "Source.xls"

    but in XLSX we get

    "/Folder/SubFolder/Source.xlsx"

    Also I noticed that the first ExternalLink within the XLS API is always blank, so if a workbook contains only 1 Externallink the ExternalLinks property will have a count of 2. Not a huge issue just odd that it happens within the XLS and XLSX. I'm not sure whether this occurred before the fix, again not an issue for us.

    Thanks for the assitance

    Kevin Logue
    Software Technology Research Centre
    Dundalk Institute of Technology
     
  •  05-26-2010, 6:50 AM 240075 in reply to 239730

    Re: ExternalLinks XLSX

    Any update on this, this leaves some of our stories in limbo without this functionality


    Kevin Logue
    Software Technology Research Centre
    Dundalk Institute of Technology
     
Page 1 of 2 (19 items)   1 2 Next >
View as RSS news feed in XML