<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Roundtrip to Shanghai via Tokyo &#187; excel</title>
	<atom:link href="http://kohei.us/tag/excel/feed/" rel="self" type="application/rss+xml" />
	<link>http://kohei.us</link>
	<description>Kohei Yoshida&#039;s Webspace</description>
	<lastBuildDate>Wed, 14 Dec 2011 04:17:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>mso-dumper now packaged in OBS</title>
		<link>http://kohei.us/2010/03/20/mso-dumper-now-packaged-in-obs/</link>
		<comments>http://kohei.us/2010/03/20/mso-dumper-now-packaged-in-obs/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 03:06:23 +0000</pubDate>
		<dc:creator>Kohei Yoshida</dc:creator>
				<category><![CDATA[]]></category>
		<category><![CDATA[calc]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[mso-dumper]]></category>
		<category><![CDATA[power point]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://kohei.us/?p=699</guid>
		<description><![CDATA[I&#8217;m happy to announce that the mso-dumper tool is now packaged in the openSUSE build service under my home repository. This tool is written in Python, and allows you to dump the contents of MS Office documents stored in the &#8230; <a href="http://kohei.us/2010/03/20/mso-dumper-now-packaged-in-obs/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m happy to announce that the mso-dumper tool is now <a href="http://download.opensuse.org/repositories/home:/kohei_yoshida/">packaged in the openSUSE build service under my home repository</a>.  This tool is written in Python, and allows you to dump the contents of MS Office documents stored in the BIFF-structured binary file format in a more human readable fashion.  It is an indispensable tool when dealing with importing from and/or exporting to the Office documents.  Right now, only Excel and Power Point formats are supported.</p>
<p>This package provides two new commands <code>xls-dump</code> and <code>ppt-dump</code>.  If you wish to dump the content of an Excel document, all you have to do is</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">xls-dump .<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>mydoc.xls</pre></div></div>

<p>and it dumps its content to standard output.  What the output looks like depends on what&#8217;s stored with the document, but it will look something like this:</p>
<pre>
...
0085h: =============================================================
0085h: BOUNDSHEET - Sheet Information (0085h)
0085h:   size = 14
0085h: -------------------------------------------------------------
0085h: B4 09 00 00 00 00 06 00 53 68 65 65 74 31
0085h: -------------------------------------------------------------
0085h: BOF position in this stream: 2484
0085h: sheet name: Sheet1
0085h: hidden state: visible
0085h: sheet type: worksheet or dialog sheet

008Ch: =============================================================
008Ch: COUNTRY - Default Country and WIN.INI Country (008Ch)
008Ch:   size = 4
008Ch: -------------------------------------------------------------
008Ch: 01 00 01 00 

00EBh: =============================================================
00EBh: MSODRAWINGGROUP - Microsoft Office Drawing Group (00EBh)
00EBh:   size = 90
00EBh: -------------------------------------------------------------
00EBh: 0F 00 00 F0 52 00 00 00 00 00 06 F0 18 00 00 00
00EBh: 02 04 00 00 02 00 00 00 02 00 00 00 01 00 00 00
00EBh: 01 00 00 00 02 00 00 00 33 00 0B F0 12 00 00 00
00EBh: BF 00 08 00 08 00 81 01 09 00 00 08 C0 01 40 00
00EBh: 00 08 40 00 1E F1 10 00 00 00 0D 00 00 08 0C 00
00EBh: 00 08 17 00 00 08 F7 00 00 10 

00FCh: =============================================================
00FCh: SST - Shared String Table (00FCh)
00FCh:   size = 8
00FCh: -------------------------------------------------------------
00FCh: 00 00 00 00 00 00 00 00
00FCh: -------------------------------------------------------------
00FCh: total number of references: 0
00FCh: total number of unique strings: 0
...
</pre>
<p>I have originally written this tool to deal with the Excel import and export part of Calc&#8217;s development, and continue to develop it further.  <a href="http://blog.thebehrens.net/">Thorsten Behrens</a> has later joined forces and <a href="http://blog.thebehrens.net/2009/01/08/python-binary-ppt-fun/">added support for the Power Point format</a>.  Right now, I&#8217;m working on adding an XML output format option to make it easier to compare outputs, which is important for regression testing.</p>
]]></content:encoded>
			<wfw:commentRss>http://kohei.us/2010/03/20/mso-dumper-now-packaged-in-obs/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ODF Support in MS Office 2007</title>
		<link>http://kohei.us/2009/04/29/odf-support-in-ms-office-2007/</link>
		<comments>http://kohei.us/2009/04/29/odf-support-in-ms-office-2007/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 14:28:17 +0000</pubDate>
		<dc:creator>Kohei Yoshida</dc:creator>
				<category><![CDATA[]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[ms office]]></category>
		<category><![CDATA[odf]]></category>
		<category><![CDATA[openoffice.org]]></category>

		<guid isPermaLink="false">http://kohei.us/?p=432</guid>
		<description><![CDATA[I guess it&#8217;s all over the news right now, that the latest service pack (SP2) for MS Office 2007 will enable Office to import and export ODF natively. This blog piece by Doug Mahugh touches on the word processor part &#8230; <a href="http://kohei.us/2009/04/29/odf-support-in-ms-office-2007/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I guess it&#8217;s all over the news right now, that the latest service pack (SP2) for MS Office 2007 will enable Office to import and export ODF natively.  <a href="http://blogs.msdn.com/dmahugh/archive/2009/04/28/working-with-odf-in-word-2007-sp2.aspx">This blog piece</a> by Doug Mahugh touches on the word processor part of their ODF support.  I haven&#8217;t yet tried it myself, but judging by Doug&#8217;s blog article it looks pretty impressive.</p>
<p>But, being more of a spreadsheet person, I&#8217;m personally more interested in how it fares in Excel to Calc interoperability.  Since their ODF support is on ODF 1.1, which predates the <a href="http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=office-formula">on-going OpenFormula specification work</a>, I&#8217;d be interested to see how compatible the formulas are.  Technically speaking, as of ODF 1.1, interpreting formula expressions was pretty much application-specific, so I would not be surprised even if they are not compatible at all.  But we&#8217;ll just have to see.</p>
<p>Either way, I find this news very encouraging.  This is undoubtedly a big step toward proliferation of ODF as a practical document exchange format.</p>
]]></content:encoded>
			<wfw:commentRss>http://kohei.us/2009/04/29/odf-support-in-ms-office-2007/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Encrypting an Excel document with password from Calc</title>
		<link>http://kohei.us/2008/07/21/encrypting-an-excel-document-with-password-from-calc/</link>
		<comments>http://kohei.us/2008/07/21/encrypting-an-excel-document-with-password-from-calc/#comments</comments>
		<pubDate>Mon, 21 Jul 2008 15:12:55 +0000</pubDate>
		<dc:creator>Kohei Yoshida</dc:creator>
				<category><![CDATA[]]></category>
		<category><![CDATA[calc]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[feature]]></category>
		<category><![CDATA[go-oo]]></category>
		<category><![CDATA[openoffice.org]]></category>

		<guid isPermaLink="false">http://kohei.us/2008/07/21/encrypting-an-excel-document-with-password-from-calc/</guid>
		<description><![CDATA[The feature of exporting an Excel document encrypted with a password has landed! Now you can save a spreadsheet document as an Excel document with password protection and open it in Excel with that password. The proof is in the &#8230; <a href="http://kohei.us/2008/07/21/encrypting-an-excel-document-with-password-from-calc/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The feature of exporting an Excel document encrypted with a password has landed!  Now you can save a spreadsheet document as an Excel document with password protection and open it in Excel with that password.  The proof is in the following screenshot (the colored emphasis is mine):</p>
<p><img src='http://kohei.us/wp-content/uploads/2008/07/excel_save_with_password.png' alt='Saving a Calc document as Excel with password protection (with encryption)' /></p>
<p>This feature is now available in the <a href="http://go-oo.org/">go-oo</a> version of OOo.  This also means that, when you edit &#038; save an existing Excel document that has already been encrypted, it will get saved encrypted.  Previously when you did this, Calc would save it un-encrypted and you would lose your password protection, which was not good and was a deal breaker for a certain segment of users.</p>
<p>The upstream effort of this feature is underway in the <a href="http://eis.services.openoffice.org/EIS2/cws.ShowCWS?Path=DEV300%2Fscsheetprotection02">scsheetprotection02</a> CWS.  That CWS also contains another enhancement for sheet and document structure protection (sounds similar but totally unrelated to this document encryption feature), and as soon as I take care of upstreaming that enhancement, I can push the whole CWS for upstream integration.  The bad news is that, because that requires a change in the ODF file format &#038; UI change, it will probably take some time before it can be integrated upstream.  But I&#8217;m making slow but steady progress there, so I&#8217;ll keep you guys updated.</p>
<p>Meanwhile, please test the <a href="http://go-oo.org/">go-oo</a> version for this encryption feature to see if there is any document that Calc fails to encrypt properly (that means Excel can&#8217;t open it), and report any bugs to us.  I&#8217;ve done my own testing, but it&#8217;s never as good as many other users testing it.  So, thanks!</p>
<p>P.S. Actually this feature has been available for at least two months in the 3.0 branch, but I wanted to see <a href="http://www.openoffice.org/issues/show_bug.cgi?id=90178">this bug</a> fixed before writing a blog about this so that I could take a pretty screenshot with all texts displayed.</p>
]]></content:encoded>
			<wfw:commentRss>http://kohei.us/2008/07/21/encrypting-an-excel-document-with-password-from-calc/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>New sheet protection dialog</title>
		<link>http://kohei.us/2008/05/08/new-sheet-protection-dialog/</link>
		<comments>http://kohei.us/2008/05/08/new-sheet-protection-dialog/#comments</comments>
		<pubDate>Fri, 09 May 2008 03:06:26 +0000</pubDate>
		<dc:creator>Kohei Yoshida</dc:creator>
				<category><![CDATA[]]></category>
		<category><![CDATA[calc]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[feature]]></category>
		<category><![CDATA[openoffice.org]]></category>

		<guid isPermaLink="false">http://kohei.us/2008/05/08/new-sheet-protection-dialog/</guid>
		<description><![CDATA[I&#8217;ve just finished designing a new dialog for Calc&#8217;s sheet protection functionality to allow optional sheet protection options. This was actually my first time designing a dialog from scratch instead of modifying an existing one, so I had to dig &#8230; <a href="http://kohei.us/2008/05/08/new-sheet-protection-dialog/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just finished designing a new dialog for Calc&#8217;s sheet protection functionality to allow optional sheet protection options.  This was actually my first time designing a dialog from scratch instead of modifying an existing one, so I had to dig around and figure out how to add a dialog.  It turns out that it is actually very simple once you know what to do.  After several hours of creative designing process, I&#8217;ve come up with something I can show to people.  So here it is:</p>
<p><img src='http://kohei.us/wp-content/uploads/2008/05/calc_sheet_protection_dialog.png' alt='sheet protection dialog screenshot' /></p>
<p>One thing to note: obviously this dialog is inspired by the similar functionality offered by Excel, and Excel provides many more options for sheet protection than just the two I&#8217;m showing here.  The reason I only have two at the moment is because I&#8217;ve only implemented support for those two options in Calc core.  When we support more options in the core, we can easily add them to the dialog.</p>
<p>This work is on-going in <a href="http://eis.services.openoffice.org/EIS2/cws.ShowCWS?Path=DEV300%2Fscsheetprotection02">scsheetprotection02</a> CWS.  Aside from the new dialog and sheet protection options, this CWS contains my other work on the binary Excel export encryption as well as sheet and document password interoperability between Excel and Calc.  I&#8217;m trying to wrap this up, so hopefully I can come up with something that people can try out soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://kohei.us/2008/05/08/new-sheet-protection-dialog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Excel workbook and worksheet protection</title>
		<link>http://kohei.us/2008/02/03/excel-workbook-and-worksheet-protection/</link>
		<comments>http://kohei.us/2008/02/03/excel-workbook-and-worksheet-protection/#comments</comments>
		<pubDate>Sun, 03 Feb 2008 22:48:00 +0000</pubDate>
		<dc:creator>Kohei Yoshida</dc:creator>
				<category><![CDATA[]]></category>
		<category><![CDATA[calc]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[feature]]></category>
		<category><![CDATA[openoffice.org]]></category>

		<guid isPermaLink="false">http://kohei.us/2008/02/03/excel-workbook-and-worksheet-protection/</guid>
		<description><![CDATA[I didn&#8217;t mean to keep this a secret, but I&#8217;ve been working on two tasks since December to further enhance Calc&#8217;s interoperability with Excel. The first one is to support correct import of an Excel document that includes password-protected worksheets, &#8230; <a href="http://kohei.us/2008/02/03/excel-workbook-and-worksheet-protection/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I didn&#8217;t mean to keep this a secret, but I&#8217;ve been working on two tasks since December to further enhance Calc&#8217;s interoperability with Excel.  The first one is to support correct import of an Excel document that includes password-protected worksheets, and the second one is to support exporting of a Calc document into an encrypted Excel format with password protection.</p>
<h3>Workbook and worksheet protection with password</h3>
<p>Currently, when Calc imports an Excel document with password-protected sheet, it retains the protected state but discards the password.  What I&#8217;m trying to do is to retain the password if the sheet is password-protected and also export the sheet password when that document is exported back into Excel.</p>
<p>The difficulty of retaining a sheet password from Excel all lies in finding out the correct password hashing function that Excel uses, then the rest will be easy.  This is because when you type in your password to protect a worksheet, Excel doesn&#8217;t store the actual password text, but immediately hashes it and stores that hash value in the document instead of the original text (BTW, Calc does the same).  So, if you don&#8217;t know the correct hashing algorithm that generates an identical hash value given the same password, all bets are off.</p>
<p>As I covered in my <a href="http://kohei.us/2008/01/18/excel-sheet-protection-password-hash/">previous blog post</a>, however, this has already been taken care of.  On top of that, Excel uses the same hashing function for both worksheet and workbook protections, so we can take care of both types of protections with just this one hashing function mentioned in my previous blog.</p>
<p>There is one important thing to note here.  This worksheet-level protection is primarily for preventing accidental editing of protected worksheet during run-time, and this still does not prevent the content of such &#8220;protected&#8221; worksheet from being modified by directly altering the content of the file itself.  This is because the content of the protected worksheet is not encrypted inside the file, so this level of password &#8220;protection&#8221; can be easily circumvented.</p>
<h3>Workbook-level protection with password</h3>
<p>Now, Excel also offers a workbook-level protection with password that actually involves encryption of document&#8217;s content, and that&#8217;s the second task I&#8217;ve been working on.  There are two instances where Excel encrypts the workbook content:</p>
<ol>
<li>when you protect workbook&#8217;s structure (you can either protect the workbook structure, windows or both for workbook-level protection) or</li>
<li>when you set a password from the Save As dialog (click on <em>Tools</em> near the upper-right corner and select <em>General Options</em>).</li>
</ol>
<p>Currently, Calc can open an encrypted Excel document, but cannot save it back with the content still encrypted.  So, when you open such a document and save it, it loses its content encryption (though a warning dialog is displayed before it writes the content back to the file unencrypted).  What I&#8217;m trying to do is to allow the user to save the content of an already encrypted document back encrypted, or save a new Calc document to an encrypted Excel document with password protection.</p>
<p>This work is still on-going, but I&#8217;m pretty confident that the hardest part is already over.  What makes this task really hard is the fact that Excel doesn&#8217;t encrypt the entire file stream, but encrypts only the record contents and leaves the record headers unencrypted.  Also, certain records, and even parts of certain records, are not encrypted.  If the entire file stream was encrypted, it would be relatively simpler to put an encryption layer on top of the normal record stream.  But because some parts of the stream are not encrypted, it is necessary to check every single record that we write to make sure that we are encrypting only the right parts of the stream, or else Excel will not load the document at all.  But like I said, the worst is over.  I can now correctly generate an encrypted Excel file with various content types: even those documents with form controls, charts, cell comments, autoshapes, and OLE objects.</p>
<p>One interesting trivia.  The encryption algorithm that Excel uses to encrypt a document requires a password, but Excel allows document encryption without a password.  So, what does Excel do if no password is given?  It uses the default password <em>VelvetSweatshop</em>. :-)</p>
<p>Anyway, both of these tasks are on-going in the <a href="http://eis.services.openoffice.org/EIS2/cws.ShowCWS?Path=SRC680%2Fscsheetprotection01">scsheetprotection01</a> CWS.  The original IZ issues are <a href="http://www.openoffice.org/issues/show_bug.cgi?id=60305">i60305</a> and <a href="http://www.openoffice.org/issues/show_bug.cgi?id=84766">i84766</a>.  There is still some work ahead before I can get this CWS integrated, but I&#8217;m making progress.  Thank you, ladies and gentlemen.</p>
]]></content:encoded>
			<wfw:commentRss>http://kohei.us/2008/02/03/excel-workbook-and-worksheet-protection/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Excel sheet protection password hash</title>
		<link>http://kohei.us/2008/01/18/excel-sheet-protection-password-hash/</link>
		<comments>http://kohei.us/2008/01/18/excel-sheet-protection-password-hash/#comments</comments>
		<pubDate>Fri, 18 Jan 2008 23:35:58 +0000</pubDate>
		<dc:creator>Kohei Yoshida</dc:creator>
				<category><![CDATA[]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[code snippet]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[ooxml]]></category>

		<guid isPermaLink="false">http://kohei.us/2008/01/18/excel-workbookworksheet-protection-password-hash/</guid>
		<description><![CDATA[When you protect either your workbook or one of your worksheets with a password in Excel, Excel internally generates a 16-bit hash of your password and stores it instead of the original password text. The hashing algorithm used for that &#8230; <a href="http://kohei.us/2008/01/18/excel-sheet-protection-password-hash/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When you protect either your workbook or one of your worksheets with a password in Excel, Excel internally generates a 16-bit hash of your password and stores it instead of the original password text.  The hashing algorithm used for that was previously unknown, but thanks to the infamous <a href="http://www.ecma-international.org/publications/standards/Ecma-376.htm">Office Open XML specification</a> it is now documented for the world to see (take a look at <em>Part 4, Section 3.3.1.81 &#8211; Sheet Protection Options</em> for the details).  Thankfully, the algorithm is identical for all recent versions of Excel including XP, 2003 and 2007, so you can simply reuse the documented algorithm for the older versions of Excel too.</p>
<p>But alas! the documented algorithm is incorrect; it does not produce correct hash values.  Being determined to find out the correct algorithm, however, I started to analyze the hashes that the documented algorithm produces, and compare them with the real hash values that Excel generates, in order to decipher the correct algorithm.</p>
<p>In the end, the documented algorithm was, although not accurate, pretty close enough that I was able to make a few changes and derive the algorithm that generates correct values.  The following code:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #339900;">#include &lt;stdio.h&gt;</span>
&nbsp;
<span style="color: #0000ff;">using</span> <span style="color: #0000ff;">namespace</span> std<span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">typedef</span> <span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">char</span> sal_uInt8<span style="color: #008080;">;</span>
<span style="color: #0000ff;">typedef</span> <span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">short</span> sal_uInt16<span style="color: #008080;">;</span>
&nbsp;
sal_uInt16 getPasswordHash<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">const</span> <span style="color: #0000ff;">char</span><span style="color: #000040;">*</span> szPassword<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    sal_uInt16 cchPassword <span style="color: #000080;">=</span> <span style="color: #0000dd;">strlen</span><span style="color: #008000;">&#40;</span>szPassword<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    sal_uInt16 wPasswordHash <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span>cchPassword<span style="color: #008000;">&#41;</span>
        <span style="color: #0000ff;">return</span> wPasswordHash<span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #0000ff;">const</span> <span style="color: #0000ff;">char</span><span style="color: #000040;">*</span> pch <span style="color: #000080;">=</span> <span style="color: #000040;">&amp;</span>szPassword<span style="color: #008000;">&#91;</span>cchPassword<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span>pch<span style="color: #000040;">--</span> <span style="color: #000040;">!</span><span style="color: #000080;">=</span> szPassword<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        wPasswordHash <span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>wPasswordHash <span style="color: #000080;">&gt;&gt;</span> <span style="color: #0000dd;">14</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">&amp;</span> <span style="color: #208080;">0x01</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">|</span> 
                        <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>wPasswordHash <span style="color: #000080;">&lt;&lt;</span> <span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">&amp;</span> <span style="color: #208080;">0x7fff</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
        wPasswordHash <span style="color: #000040;">^</span><span style="color: #000080;">=</span> <span style="color: #000040;">*</span>pch<span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    wPasswordHash <span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>wPasswordHash <span style="color: #000080;">&gt;&gt;</span> <span style="color: #0000dd;">14</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">&amp;</span> <span style="color: #208080;">0x01</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">|</span> 
                    <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>wPasswordHash <span style="color: #000080;">&lt;&lt;</span> <span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">&amp;</span> <span style="color: #208080;">0x7fff</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    wPasswordHash <span style="color: #000040;">^</span><span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #208080;">0x8000</span> <span style="color: #000040;">|</span> <span style="color: #008000;">&#40;</span><span style="color: #FF0000;">'N'</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #0000dd;">8</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">|</span> <span style="color: #FF0000;">'K'</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    wPasswordHash <span style="color: #000040;">^</span><span style="color: #000080;">=</span> cchPassword<span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #0000ff;">return</span> wPasswordHash<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">int</span> main <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> argc, <span style="color: #0000ff;">char</span><span style="color: #000040;">**</span> argv<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>argc <span style="color: #000080;">&lt;</span> <span style="color: #0000dd;">2</span><span style="color: #008000;">&#41;</span>
        <span style="color: #0000dd;">exit</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #0000dd;">printf</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;input password = %s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>, argv<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    sal_uInt16 hash <span style="color: #000080;">=</span> getPasswordHash<span style="color: #008000;">&#40;</span>argv<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #0000dd;">printf</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;hash = %4.4X<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>, hash<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>produces the right hash value from an arbitrary password.  One caveat: this algorithm takes an 8-bit char array, so if the input value consists of 16-bit unicode characters, it needs to be first converted into 8-bit character array.  The conversion algorithm is also documented in the OOXML specification.  I have not tested it yet, but I hope that algorithm is correct. ;-)</p>
]]></content:encoded>
			<wfw:commentRss>http://kohei.us/2008/01/18/excel-sheet-protection-password-hash/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Importing Excel 2007 files</title>
		<link>http://kohei.us/2007/06/20/importing-excel-2007-files/</link>
		<comments>http://kohei.us/2007/06/20/importing-excel-2007-files/#comments</comments>
		<pubDate>Wed, 20 Jun 2007 04:00:10 +0000</pubDate>
		<dc:creator>Kohei Yoshida</dc:creator>
				<category><![CDATA[]]></category>
		<category><![CDATA[calc]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[ooxml]]></category>
		<category><![CDATA[openoffice.org]]></category>

		<guid isPermaLink="false">http://blog.kohei.us/2007/06/20/importing-excel-2007-files/</guid>
		<description><![CDATA[The Excel 2007 filter for Calc is still on its way, but perhaps now is a good time to show the progress of this new Excel 2007 import filter work by Daniel Rentz and myself. Here is a screenshot of &#8230; <a href="http://kohei.us/2007/06/20/importing-excel-2007-files/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The Excel 2007 filter for Calc is still on its way, but perhaps now is a good time to show the progress of this new Excel 2007 import filter work by Daniel Rentz and myself.</p>
<p>Here is a screenshot of a file created by Excel 2007 (left), and one for the same file opened in Calc (right).</p>
<p align="center"><a href="http://blog.kohei.us/wp-content/uploads/2007/06/xlsx-shot-win.png" title="Excel 2007 screenshot"><img src="http://blog.kohei.us/wp-content/uploads/2007/06/xlsx-shot-win.thumbnail.png" alt="Excel 2007 screenshot" /></a> <a href="http://blog.kohei.us/wp-content/uploads/2007/06/xlsx-shot-calc.png" title="Excel 2007 file opened in Calc"><img src="http://blog.kohei.us/wp-content/uploads/2007/06/xlsx-shot-calc.thumbnail.png" alt="Excel 2007 file opened in Calc" /></a></p>
<p>There are still a lot to be done, however.  Formula import is still to be completed, which blocks other features that rely on the formula parser.  Charts, text boxes, and other graphic objects are still not imported yet.  There is also <a href="http://www.openoffice.org/issues/show_bug.cgi?id=78673">a performance issue of a large xlsx file import</a>, which needs to be addressed at some point.</p>
<p>But all in all, things are coming along very nicely.</p>
]]></content:encoded>
			<wfw:commentRss>http://kohei.us/2007/06/20/importing-excel-2007-files/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

