title: file signature 0A 0A 0A
body: <p>I made an account on this site because of a problem I've been struggling with for a few days now. I'm trying to make a java program that can login to a secured site and download a certain Excel file (using valid credentials, nothing illegal!)</p>
  
  <p>However, when I try to open the excel file, I get a <code>NotOle2FileException</code>. The file I'm trying to download/read is an excel file, but it's hosted on a SharePoint environment that automatically opens it with the Excel Web App... The header signature I'm getting is <code>0x6C6D74683C0A0A0A</code> and should be <code>0xE11AB1A1E011CFD0</code> (&lt;- Excel OLE2 format)...</p>
  
  <p>does anyone have any idea what the file signature i'm getting refers to ? Does it have to do anything with the excel file being embedded on the site in some way?</p>
  
  <p>Codewise I'm trying this:</p>
  
  <pre><code>URLConnection uc = anchor.click().getUrl().openConnection();
      Workbook workbook;
      workbook = getWorkbook(uc);
  
      private Workbook getWorkbook(URLConnection uc) throws IOException {
      Workbook workbook = null;
      System.out.println(uc.getURL());
      if (uc.getURL().toString().endsWith("xls")) {
         workbook = new XSSFWorkbook(uc.getInputStream());
      } else if (uc.getURL().toString().endsWith("xlsx")) {
          workbook = new HSSFWorkbook(uc.getInputStream());
      } else {
          throw new IllegalArgumentException("The specified path is not an excel file");
      }
  
      return workbook;
      }
  </code></pre>
  
  <p>The anchor refers to the element on the website that links to the excel file (can't be hardcoded since I want to be able to download different files, depending on user input) basicly: the <code>href</code> attribute of the anchor links to an url ending on .xlsx</p>
  
  <p>EDIT: so the signature would be a htmlpage, but when trying to save it as HtmlPage i'm getting the following error:</p>
  
  <pre><code>java.lang.ClassCastException: com.gargoylesoftware.htmlunit.UnexpectedPage cannot be cast to com.gargoylesoftware.htmlunit.html.HtmlPage
  </code></pre>