<?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>Do Know Evil - A Blog by Tyler Mulligan &#187; Microsoft</title> <atom:link href="http://www.doknowevil.net/category/computers/software/microsoft/feed/" rel="self" type="application/rss+xml" /><link>http://www.doknowevil.net</link> <description>Tips and Tricks About Computers, Web Development, Linux, the Internet and the Like</description> <lastBuildDate>Sat, 16 Jul 2011 01:25:35 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0.5</generator> <item><title>List the contents of a zip file</title><link>http://www.doknowevil.net/2008/01/03/list-the-contents-of-a-zip-file/</link> <comments>http://www.doknowevil.net/2008/01/03/list-the-contents-of-a-zip-file/#comments</comments> <pubDate>Thu, 03 Jan 2008 15:23:09 +0000</pubDate> <dc:creator>Tyler Mulligan</dc:creator> <category><![CDATA[Microsoft]]></category> <category><![CDATA[Organization]]></category> <category><![CDATA[Windows]]></category> <category><![CDATA[zip]]></category><guid isPermaLink="false">http://www.doknowevil.net/2008/01/03/list-the-contents-of-a-zip-file/</guid> <description><![CDATA[I post a lot of zip files on forums to trade information with my fellow gamers, programmers, internetards and what have you. As such, I like to tell them what the zip contains. Now the title of this post is a bit of a misnomer as I haven&#8217;t really created the zip yet&#8230; but I]]></description> <content:encoded><![CDATA[<p>I post a lot of zip files on forums to trade information with my fellow gamers, programmers, internetards and what have you.  As such, I like to tell them what the zip contains.  Now the title of this post is a bit of a misnomer as I haven&#8217;t really created the zip yet&#8230; but I figured it would be just as helpful.  The only extra step you would have in doing an actual zip file would be to extract the files to a folder but enough of the intro, lets dive in.</p><p><b>Step one</b>: Have a folder with the files you want to list</p><p><a href='http://www.doknowevil.net/wp-content/uploads/2008/01/zip_contents.png' title='Folder with files'><img src='http://www.doknowevil.net/wp-content/uploads/2008/01/zip_contents-150x150.png' alt='Folder with files' /></a><br /> (Whats with your image icons d00d? My images are associated with irfanview)</p><p><b>Step two</b>: Open the Command prompt.</p><p>Do this by going to <b>start</b> -> <b>Run&#8230;</b> and typing in &#8220;<b>cmd</b>&#8221;</p><p><img src='http://www.doknowevil.net/wp-content/uploads/2008/01/zip_contents_1.png' alt='cmd' /></p><p><b>Step three</b>: Navigate to your folder with &#8220;<b>cd</b>&#8221; (change directory) and list the files without any attributes using &#8220;<b>dir /b</b>&#8221;</p><p><a href='http://www.doknowevil.net/wp-content/uploads/2008/01/zip_contents_2.png' title='Change directory'><img src='http://www.doknowevil.net/wp-content/uploads/2008/01/zip_contents_2-150x150.png' alt='Change directory' /></a></p><p><b>Step four</b>: Right click anywhere in the black and choose, &#8220;<b>Mark</b>&#8220;, this allows you to highlight the outputted text.</p><p><a href='http://www.doknowevil.net/wp-content/uploads/2008/01/zip_contents_3.png' title='cmd - Mark'><img src='http://www.doknowevil.net/wp-content/uploads/2008/01/zip_contents_3-150x150.png' alt='cmd - Mark' /></a></p><p>Highlight your filelist</p><p><a href='http://www.doknowevil.net/wp-content/uploads/2008/01/zip_contents_4.png' title='Highlighted Text'><img src='http://www.doknowevil.net/wp-content/uploads/2008/01/zip_contents_4-150x150.png' alt='Highlighted Text' /></a></p><p>When you right click again, the text is copied to your clipboard and you can paste it anywhere you&#8217;d like</p><p><img src='http://www.doknowevil.net/wp-content/uploads/2008/01/zip_contents_5.png' alt='Paste the text' /></p> ]]></content:encoded> <wfw:commentRss>http://www.doknowevil.net/2008/01/03/list-the-contents-of-a-zip-file/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>NO to the Microsoft Office format as an ISO standard</title><link>http://www.doknowevil.net/2007/12/16/no-to-the-microsoft-office-format-as-an-iso-standard/</link> <comments>http://www.doknowevil.net/2007/12/16/no-to-the-microsoft-office-format-as-an-iso-standard/#comments</comments> <pubDate>Sun, 16 Dec 2007 17:08:31 +0000</pubDate> <dc:creator>Tyler Mulligan</dc:creator> <category><![CDATA[Microsoft]]></category> <category><![CDATA[XML]]></category><guid isPermaLink="false">http://www.doknowevil.net/2007/12/16/no-to-the-microsoft-office-format-as-an-iso-standard/</guid> <description><![CDATA[I ask the national members of ISO to vote &#8220;NO&#8221; in the ballot of ISO DIS 29500 (Office OpenXML or OOXML format) for the following reasons: 1. There is already a standard ISO26300 named Open Document Format (ODF): a dual standard adds costs, uncertainty and confusion to industry, government and citizens; 2. There is no]]></description> <content:encoded><![CDATA[<blockquote><p> I ask the national members of ISO to vote &#8220;NO&#8221; in the ballot of ISO DIS 29500 (Office OpenXML or OOXML format) for the following reasons:</p><p> 1. There is already a standard ISO26300 named Open Document Format (ODF): a dual standard adds costs, uncertainty and confusion to industry, government and citizens;<br /> 2. There is no provable implementation of the OOXML specification: Microsoft Office 2007 produces a special version of OOXML, not a file format which complies with the OOXML specification;<br /> 3. There is information missing from the specification document, for example how to do a autoSpaceLikeWord95 or useWord97LineBreakRules;<br /> 4. More than 10% of the examples mentioned in the proposed standard do not validate as XML;<br /> 5. There is no guarantee that anybody can write software that fully or partially implements the OOXML specification without being liable to patent lawsuits or patent license fees by Microsoft;<br /> 6. This format conflicts with existing ISO standards, such as ISO 8601 (Representation of dates and times), ISO 639 (Codes for the Representation of Names and Languages) or ISO/IEC 10118-3 (cryptographic hash);<br /> 7. There is a bug in the spreadsheet file format which forbids any date before the year 1900: such bugs affect the OOXML specification as well as software applications like Microsoft Excel 2000, XP, 2003 and 2007.<br /> 8. This standard proposal was not created by bringing together the experience and expertise of all interested parties (such as the producers, sellers, buyers, users and regulators), but by Microsoft alone.</p></blockquote><p><a href="http://www.noooxml.org/petition" target="_blank">Sign the petition here</a></p> ]]></content:encoded> <wfw:commentRss>http://www.doknowevil.net/2007/12/16/no-to-the-microsoft-office-format-as-an-iso-standard/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Using PHP to Make Excel Easier</title><link>http://www.doknowevil.net/2007/05/12/using-php-to-make-excel-easier/</link> <comments>http://www.doknowevil.net/2007/05/12/using-php-to-make-excel-easier/#comments</comments> <pubDate>Sat, 12 May 2007 15:38:39 +0000</pubDate> <dc:creator>Tyler Mulligan</dc:creator> <category><![CDATA[Excel]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Programming]]></category><guid isPermaLink="false">http://www.doknowevil.net/?p=12</guid> <description><![CDATA[Recently, I was presented with the task of counting the number times filenames repeated in an excel document. Being a 16,000+ row file, with well over 500 unique filenames, there was no simple solution in excel. Having some experience exporting excel documents using PHP, I knew importing them wouldn’t be too hard. A few google]]></description> <content:encoded><![CDATA[<p>Recently, I was presented with the task of counting the number times filenames repeated in an excel document.  Being a 16,000+ row file, with well over 500 unique filenames, there was no simple solution in excel.</p><p>Having some experience exporting excel documents using PHP, I knew importing them wouldn’t be too hard.  A few google searches later and I came across <a href="http://sourceforge.net/projects/xlreader" target="_blank">Excel Reader</a> which fit the bill perfectly.</p><p>After sorting my excel document by filename, I created a loop in PHP that would read the first filename, count the number of times it repeated until it changed, then append that data to a string that would be exported to a new excel document once it was done reading the data.</p><pre class="brush:php">
// Starting at 2 to skip the headers | +1 so it compares the last row
for ($i = 2; $i &lt;= $data-&gt;sheets[0][&#039;numRows&#039;]+1; $i++) {
	if ($data-&gt;sheets[0][&#039;cells&#039;][$i][3]==$curFileName) {
		$curFileCount++;
	} else {
		// Output the data line:
&quot;Device&quot;,&quot;User&quot;,&quot;Filename&quot;,&quot;Filecount&quot;
		$stringData =
&quot;\&quot;&quot;.$data-&gt;sheets[0][&#039;cells&#039;][$i-1][1].&quot;\&quot;,\&quot;&quot;.$data-&gt;sheets[0][&#039;cells&#039;][$i
-1][2].&quot;\&quot;,\&quot;&quot;.$data-&gt;sheets[0][&#039;cells&#039;][$i-1][3].&quot;\&quot;,\&quot;&quot;.$curFileCount.&quot;\&quot;\
n&quot;;
		fwrite($fh, $stringData);

		// Reset the count and update the curFileName
		$curFileName = $data-&gt;sheets[0][&#039;cells&#039;][$i][3];
		$curFileCount=1;
	}
	echo &quot;Row: &quot;.$i.&quot;\n&quot;;
}</pre><p>Of course&#8230; I didn&#8217;t have just one of these files but 6 and manually entering each filename would be a waste of my time.  My software solution for this was to create an &#8220;Input&#8221; and &#8220;Output&#8221; folder and have PHP cycle through the &#8220;Input&#8221; folder.</p><pre class="brush:php">
// For every file in the dir &quot;Input&quot;, generate a report
if ($handle = opendir(&#039;Input&#039;)) {
	while (false !== ($orgFileName = readdir($handle))) {
		if($orgFileName != &#039;..&#039; &amp;&amp; $orgFileName != &#039;.&#039;) {

			// Echo the file we&#039;re reading, then read that file
			echo $orgFileName.&quot;\n&quot;;
			$data-&gt;read(&quot;Input/&quot;.$orgFileName);</pre><p>Eventually it all came together as such:</p><pre class="brush:php">
&lt;?php

// Don&#039;t change any of this
require_once &#039;Excel/reader.php&#039;;
$data = new Spreadsheet_Excel_Reader();
$data-&gt;setOutputEncoding(&#039;CP1251&#039;);

// For every file in the dir &quot;Input&quot;, generate a report
if ($handle = opendir(&#039;Input&#039;)) {
	while (false !== ($orgFileName = readdir($handle))) {
		if($orgFileName != &#039;..&#039; &amp;&amp; $orgFileName != &#039;.&#039;) {

			// Echo the file we&#039;re reading
			echo $orgFileName.&quot;\n&quot;;
			$data-&gt;read(&quot;Input/&quot;.$orgFileName);

			// Set the first filename to compare
			$curFileName =
$data-&gt;sheets[0][&#039;cells&#039;][2][3]==$curFileName;
			$curFileCount = 0;

			// Create a file and open it for writing
			$myFile =
&quot;Output/File_Count-&quot;.str_replace(&quot;.xls&quot;,&quot;.csv&quot;,$orgFileName);
			$fh = fopen($myFile, &#039;w&#039;) or die(&quot;can&#039;t open file&quot;);

			// Starting at 2 to skip the headers | +1 so it
compares the last row
			for ($i = 2; $i &lt;= $data-&gt;sheets[0][&#039;numRows&#039;]+1;
$i++) {
				if
($data-&gt;sheets[0][&#039;cells&#039;][$i][3]==$curFileName) {
					$curFileCount++;
				} else {
					// Output the data line:
&quot;Device&quot;,&quot;User&quot;,&quot;Filename&quot;,&quot;Filecount&quot;
					$stringData =
&quot;\&quot;&quot;.$data-&gt;sheets[0][&#039;cells&#039;][$i-1][1].&quot;\&quot;,\&quot;&quot;.$data-&gt;sheets[0][&#039;cells&#039;][$i
-1][2].&quot;\&quot;,\&quot;&quot;.$data-&gt;sheets[0][&#039;cells&#039;][$i-1][3].&quot;\&quot;,\&quot;&quot;.$curFileCount.&quot;\&quot;\
n&quot;;
					fwrite($fh, $stringData);

					// Reset the count and update the
curFileName
					$curFileName =
$data-&gt;sheets[0][&#039;cells&#039;][$i][3];
					$curFileCount=1;
				}
				echo &quot;Row: &quot;.$i.&quot;\n&quot;;
			}
			// Close file
			fclose($fh);
		}
	}
}
?&gt;</pre><p>My apologies for the less than perfect code, I was on a deadline and perfect code wasn&#8217;t a requirement :).</p><p>Here are some screenshots of the script in action.</p><p><a href="http://www.doknowevil.net/wp-content/uploads/2007/05/php_filecount-11.png" title="PHP Excel File Count - Screenshot 1"><img src="http://www.doknowevil.net/wp-content/uploads/2007/05/php_filecount-11.png" alt="PHP Excel File Count - Screenshot 1" border="0" width="50%" height="50%" /></a></p><p><a href="http://www.doknowevil.net/wp-content/uploads/2007/05/php_filecount-21.png" title="PHP Excel File Count - Screenshot 2"><img src="http://www.doknowevil.net/wp-content/uploads/2007/05/php_filecount-21.png" alt="PHP Excel File Count - Screenshot 2" border="0" width="50%" height="50%" /></a></p><p><a href="http://www.doknowevil.net/wp-content/uploads/2007/05/php_filecount-31.png" title="PHP Excel File Count - Screenshot 3"><img src="http://www.doknowevil.net/wp-content/uploads/2007/05/php_filecount-31.png" alt="PHP Excel File Count - Screenshot 3" border="0" /></a></p><p></p> ]]></content:encoded> <wfw:commentRss>http://www.doknowevil.net/2007/05/12/using-php-to-make-excel-easier/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)
Object Caching 463/481 objects using disk

Served from: www.doknowevil.net @ 2012-02-04 03:51:44 -->
