title: how can you parse an excel (.xls) file stored in a varbinary in MS SQL 2005?
body: <p><strong>problem</strong></p>
  
  <p>how to best parse/access/extract "excel file" data stored as binary data in an SQL 2005 field?</p>
  
  <p>(so all the data can ultimately be stored in other fields of other tables.)</p>
  
  <p><strong>background</strong></p>
  
  <p>basically, our customer is requiring a large volume of verbose data from their users. unfortunately, our customer cannot require any kind of db export from their user. so our customer must supply some sort of UI for their user to enter the data. the UI our customer decided would be acceptable to all of their users was excel as it has a reasonably robust UI. so given all that, and our customer needs this data parsed and stored in their db automatically.</p>
  
  <p>we've tried to convince our customer that the users will do this exactly once and then insist on db export! but the customer can not <em>require</em> db export of their users.</p>
  
  <ul>
  <li>our customer is requiring us to parse an excel file</li>
  <li>the customer's users are using excel as the "best" user interface to enter all the required data</li>
  <li>the users are given blank excel templates that they must fill out
  
  <ul>
  <li>these templates have a fixed number of uniquely named tabs</li>
  <li>these templates have a number of fixed areas (cells) that must be completed</li>
  <li>these templates also have areas where the user will insert up to thousands of identically formatted rows</li>
  </ul></li>
  <li>when complete, the excel file is submitted from the user by standard html file upload</li>
  <li>our customer stores this file raw into their SQL database</li>
  </ul>
  
  <p><strong>given</strong></p>
  
  <ul>
  <li>a standard excel (".xls") file (native format, not comma or tab separated)</li>
  <li>file is stored raw in a <code>varbinary(max)</code> SQL 2005 field</li>
  <li>excel file data may not necessarily be "uniform" between rows -- i.e., we can't just assume one column is all the same data type (e.g., there may be row headers, column headers, empty cells, different "formats", ...)</li>
  </ul>
  
  <p><strong>requirements</strong></p>
  
  <ul>
  <li>code completely within SQL 2005 (stored procedures, SSIS?)</li>
  <li>be able to access values on any worksheet (tab)</li>
  <li>be able to access values in any cell (no formula data or dereferencing needed)</li>
  <li>cell values must not be assumed to be "uniform" between rows -- i.e., we can't just assume one column is all the same data type (e.g., there may be row headers, column headers, empty cells, formulas, different "formats", ...)</li>
  </ul>
  
  <p><strong>preferences</strong></p>
  
  <ul>
  <li>no filesystem access (no writing temporary .xls files)</li>
  <li>retrieve values in defined format (e.g., actual date value instead of a raw number like 39876)</li>
  </ul>