Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unable to load Excel file. Error: "Element not found"

    I can no longer import an .xlsx file into Stata. Neither the .do file code that previously worked nor the menu-based import works.

    I would like to know why this is happening. Saving the alliances sheet as a new workbook and importing that workbook works fine, but I want to know why this particular file cannot be imported, as saving as a new sheet complicates my workflow.

    Code:
    Code:
    import excel "C:\Dropbox\data\alliances-natural-resources\DATA-natural-resource-alliances.xlsx", sheet("alliances") firstrow allstring clear
    Error message using Stata 15 Import Excel menu:
    Click image for larger version

Name:	Capture.JPG
Views:	1
Size:	33.0 KB
ID:	1417111


    Background:
    • Stata 15 I/C, upgraded from Stata 13 I/C about a month ago
    • MS Office 365 ProPlus Version 1709 (Build 8528.2147 Click-to-Run)
    • MS Excel 2016 32-bit
    • Importing other .xlsx files works fine
    • Saving the alliances sheet as a new workbook and importing that workbook works fine

  • #2
    Whatever saved the workbook corrupted it, omitting an element that Stata needs to read it. Talk to whoever put the workbook up on (or download it from) Dropbox.

    Comment


    • #3
      This appears to be a month-ago issue, but I don't see in the thread if this has been resolved. Joseph, it looks to me from Nicholas' description that the original tool (let's presume this is Excel 2016 as shown in his signature) can still open the file (despite the 'corruption'). So an important question for me is:
      what is it (if anything) that is optional in the Excel file format that is required for Stata and not required for other software?

      Nicholas, perhaps :
      1) provide more details
      2) make sure your Stata installation is ok, other Excel files from different sources can be imported ok.
      3) isolate the issue from Dropbox (does the problem still persist if you place your file in "C:\Data"?)
      4) get some tools (different Excel versions, viewers, Gnumeric, Open Office, etc) and see which ones open the file and which complain. The open source software tends to be more user friendly with error messages and say something more informative, like "Element SOMETHING not found", then you will have at list a hint on what's causing it.
      5) watch for status messages, sometimes when opening files you see "Recovering..." or "Repairing...." or something else. Then you know there is definitely an issue with the file, even though it might be curable.
      6) try to create a minimal example using the same producing tool which exhibits the same problem, but which you can share with the community. If the issue is confirmed this will also be helpful to the developers to replicate the problem and formulate a patch for it.

      Finally, make sure that the file does not overshoot any limits. From the manual: "For performance, import excel imposes a size limit of 40 MB for Excel 2007/2010 (.xlsx) files." I think you should be getting a different (and proper) error message if the size is too big, but if you feel you are pushing the limits on any dimension (size, columns, rows, macros, string lengths, etc) that could lead to the cause.

      I hope the problem has been long as resolved, but since there is no explanation posted, I would very much like to learn about how it ended.

      Best, Sergiy Radyakin

      Comment


      • #4
        I've experienced this issue as well. My spreadsheet had lots of formulas, functions and the data was formatted as "table". I've solved the problem copying all data and pasting them as "numbers" in a new spreadsheet. It worked for me.

        Comment


        • #5
          Thanks to Marcio, it also works for me

          Comment


          • #6
            I got similar problem as well, I have created a tabulation using tabout into excel, and now I want to import it back to Stata using import excel command, but I get this error message "error: "the central directory is not found in the archive (or you were trying to open not the last volume of segmented archive)."

            Comment

            Working...
            X