This was a fairly easy and straight-forward job without requiring any additional APIs. Microsoft Office 2003 was pretty forgiving about Excel file extension that any auto-generated Excel file would be easily accepted without much hiccup. Nowadays, with Office 2007 and the upcoming Office 2010, we again are forced to resort to a "few" different Excel-creation techniques which yielded various pros and cons.
- The should've-been-the-easy-way: (X)HTML+CSS+Excel Formula minus-JavaScript format saved as .xls file.
- The should've-been-just-as-easy-way: Office 2003 XML format saved as .xls file.
- The what-we're-now-forced-to-do: Microsoft OpenXML SDK (2.0) way creating a warning-free Excel 2007 file (SDK 2.0 is the most recent library for Office 2010).
I think I know one of the many reasons Microsoft decided to restrict the flexibility later versions of its Office suite—something to do with all those macro/VBA-infected office files or something like that. So they now go by the "locked-down-by-default" starting point. But I also think it's a crying shame that we get all sort of warning dialogs for file extension renaming and things that are already automatically recognized by Microsoft Office suite, anyway. If only there's a way to suppress the dialog from an administrative policy instead of going to each user's PC... If anything, they should make still automatically protect the end-user while still enabling programmers maintain high-productivity by adopting web document standard but without that whole pop-up dialogs everytime so that worker-bee programmers like myself aren't forced to find, re-devise yet another technique to create, and yet again re-wrap a new set of APIs on a new SDK just to do what's supposed to be a simple thing. Do I digress? Perhaps not. We'll see with the aforementioned techniques in the following illustrations.
(X)HTML && CSS || Excel Formula !JavaScript method
This technique is as simple as it could be; there really is no other additional digging required other than what any web programmer already knows. Anyone could manually write the (X)HTML-based Excel file or use his/her favorite programming language to generate the intended file. You be the judge after seeing the code in Listing 1 below.
| This is Cell A1 in Excel | This is Cell B1 in Excel | |
| 123 | 456 | =A2+B2 |
The advantages of this technique are as apparent as the advantages of following a widely-accepted and standardized document object model, especially one that would be readily usable on a web browser. In addition, this would translate well to the natural order of a spreadsheet being a two-dimensional table understood as rows and columns made up of cells. Those as what
| and other related (X)HTML elements are for.
The one great disadvantage stemmed from an annoyance of the application (understandably) warning the user that the content format is different from what is understood by Excel when looking at an .xls file extension. And it is more often than not sufficient to put-off a client-centric programmer who cares about NOT scaring his customer as much as he does about programming ease and efficiency. Will this image: Up next (Part 2): Office 2003 XML format approach. Friday, March 06, 2009Essential Windows PowerShell CommandletsPreviously, we learned the basic commands: help and gal. I suppose now it's time to properly refer to these "commands" as commandlets or cmdlets following PowerShell's own set of terminologies. But just to note that whenever both commands and commandlets, I use them interchangeably for the same semantic meaning. Call me stubborn. Call it bad habit. But they really are all just commands to me. In any case, although I think of all of the commandlets simply as commands, we should still mentally note at the back of our mind that for "data-typing" purposes, PowerShell truly types these items or commands as Our first essential command after learning the basics is Get-Command Get-Command Get-Command outputs all of the available commands in PowerShell in a clean PowerShell installation. These are the commands that we really will use as the building blocks for writing PowerShell scripts. Through a process of trial and errors, let us try to see if we can perform the obligatory, introductory of any programming lesson: print the string "Hello World!" on screen (I promise I'll keep the trial and errors to an abridged version).
But, let's use my experience, shall we? Let's just type in the following simple command, and we'll simply get the result we want just as we'd see in Listing 1. From these output we can sort of guess which command we can use, but if in case we're still in doubt we could always do help write-debug, help write-error, etc. Soon after we go through this we'll find the command we want to use is Write-Output. That's a rather "long" command to type, though. Let's try to see if there's a shorter version of it. For this purpose, let's try what's on Listing 2. Now that we found what we want, we can try either command aliases just as in Listing 3 Sure enough, we found both yield the same result We might wonder, "Why are there two aliases for the same command?" I don't really know the answer to that question other than perhaps the alias write is the built-in alias for Write-Output and perhaps the alias echo is simply a way to help those who are used to writing .BAT scripts to transition a little more easily to Windows PowerShell. Whatever the answer to that question is rather irrelevant; what's more important is that now we've gone through the basic exercises in learning each PowerShell command. Wait wait wait!!! We're not done here! What's all that business with the where command and the rest of the strings following it? No, I didn't cheat :) I simply wanted to shortcut all the trial and errors I went through in learning PowerShell without filling the content of this notes full of garbage. Trial and errors, after all, are things we each can do individually on our own time. As for the shortcut strung with the where command, I'll note an explanation of it another time. Tuesday, March 03, 2009Basic Windows PowerShell CommandsWindows PowerShell is relatively new shell command interpreter in comparison to the venerable CMD, CScript, and Windows Script Host. Just like any shell script, it isn't really difficult to learn simply by trial and errors as long as we get the few basic commands down so we can drill further to other commands we seek to use. The most basic command we should know is, of course, help. Get-Help As the command name suggests, it is the single command we use to see the details of a particular command we submit as a parameter to the help command. Listing 1 below illustrates the help command execution. It's so helpful that we can simply type help help at the prompt to display the details of the help command itself. As we examine the command output's "Related links" section, we see three other commands related to the help command. All the three new commands we found here: Get-Command, Get-PSDrive, and Get-Member are part of the important basic commands we will discuss more thoroughly a little later. Get-Aliases "Shallow Hal wants a gal." The second basic command that is most useful to expedite our PowerShell command study is Get-Aliases also aliased as gal. First, we're gonna combine gal with the first command we learned earlier: help in Listing 2. Then, we'll try to see if sending the command twice to the shell prompt, one as the command call itself and another as the paramater to the command call gal gal in Listing 3. See! It's simple right? From Listing 2, we find the usage details of the command gal, and from Listing 3, we find that gal itself is an alias of the command Get-Aliases. But, but, but... How did I know in the beginning that help and gal are commands we can execute? The answer is as ordinary as it could be—I guessed the first command: help presuming that a program usually has a variation of help, --help, --h, man or the old-school /? in some sort of form even without reading its documentation. As for the command: gal, after having found out that while the command help could be executed and yields an output indicating the actual command name: Get-Help, I simply sought in MSDN PowerShell site a reference entry pertaining to available command aliases. Up next... We won't need to go through the details of each command, but will start our PowerShell exercises by using the three new "related" commands we learned earlier from Listing 1. Tuesday, February 17, 2009How to write clean website layout using CSS (Part 2)The pure <div/> approach: Positions Creating web page layout using CSS positioning really is a very simple thing to do. All we need to remember is that an XHTML element's absolute position is always relative to its container. That is the one thing we usually forget. We are so caught up in the semantic definition of the word absolute position we forget that it isn't absolute only in the context of the web page itself (<body/>). For a similar simple markup we wrote in Listing 2 of our previous notes, we now have the following Listing 1. The styling commands we needed in Listing 2 felt simpler to do and easier to understand from the perspective of having to think about how the browser layout engine will interpret the commands we write. I'd say it looks pretty straightforward without having spent lots of hours tweaking the style attributes to get the desired results. I was pretty happy this turned out to be easy. But then just for kicks I wanted to find out "What if I did the other way around, strictly with floats and kept all the elements' positions at its default relative value?" "Would it be just as simple?" "Would it be just as quick to do?" The pure <div/> approach: Floats With the same base structural template as Listing 1 above, I found that achievement the desired result using float method is considerably longer. Sure if you look at the last CSS code-block of Listing 2, you'll see that I actually cheated by using floats because well... that was actually the simplest way to order the <div/>'s in simple column formation. But then, to figure out which of the <div/>'s in square formation need to be floated the right way took quite a bit of trial and error in the order of magnitude of 5. Yes. Five. Listing 2 took me only a couple of minutes to write and get right. Listing 3 took me almost 15 minutes to do due to tinkering with the float and clear attribute combinations. How to write clean website layout using CSS (Part 1)There are three well-known techniques in creating a website layout using CSS:
There are others of course; very advanced CSS masters like to further enhance the cleanliness of their XHTML code without using a single <div/> or <span/>. As I jumped into refresher exercises, I wondered: "How easily would it be for me to do this (ref: screen)?" Or, "Is it even possible to easily do it for the four popular browsers today?" Warning: At the time of writing, the following materials were only proofed on:
This article merely documents these variations and choices. We do not advocate one approach versus another as these choices are left to each of our individual circumstances and reasons. Although <grin/> I would soon give up doing the first approach. The base skeletal structure for each of the tested approaches is the following Listing 1(with slight differences): The <table/> approach If we search the Internet for arguments against using <table/> tags for layout purposes, we will find them in abundance. They are all valid arguments and we should heed them. I simply could not bring myself to nest <table/> tags like it's 1999. The <table/> + <div/> approach For the following simple layout in Listing 2:
We still had the following styling code in Listing 3 Yes, this approach yields a slightly cleaner code result than only the <table/> based approach. But it isn't without its own problems. There's that <tr/> rendering issue in IE. And of course, I found that the CSS implementation differences between the various browsers render this approach virtually indefensible, as in saying: "If we have to resort to using various CSS tricks/hacks anyway, why not simply do a Table-less Layout with its pros and cons already weighed by the web design community at large, especially when we already have ample samples written by masters such as those from A LIST apart and Zen Garden—two sources of my favorites reading materials where I found a wealth of knowledge shared to us all common netizens." Need I say more? Up next: The pure <div/> approach (Part 2). Thursday, February 12, 2009How to create a new Blogger template (Part 2)Blogger's Layout Data Tags For details on why That's pretty much it. The rest, we can just drop widget definitions following this Blogger Widget article and regular X/HTML web-design exercises. The following is the result of this new Blogger template exercise.
How to create a new Blogger template (Part 1)
Dissecting a Blogger's basic default template Leave the first two lines alone. Listing 1: After the first two lines of code, a Blogger's template is essentially just a regular X/HTML document (according to the specified DOCTYPE in code line #2). Side notes: Personally, I use XHTML 1.0 Transition for reasons we'll experience when we exercise the coding style I wrote in here: How to write clean X/HTML document. For this reason, in the remaining content of this study assumes and follows the transitional document type declaration. Basic X/HTML coding An X/HTML document essentially consists of simple structural tags as seen in Listing 2 below. Despite all of the content we see when view an X/HTML document on the web, that's really all there is to it. A Blogger's template is no exception. The some differences we see in the basic template we've downloaded usually has to do with what Blogger labels "Layout Data Tags" or, for those used to using Blogger's WYSIWYG layout editing tool, "Widgets" (regardless of whether or not they're displayed on the resulting browser screen). In Blogger's document template case, there are extra namespaces declared as attributes of the <html> tag as shown in Listing 3 below. We should do the same. Tuesday, February 10, 2009How to write clean X/HTML documentWarning: XMP tag is an officially deprecated tag as of HTML specification 3.02. So follow this advise at your own risk. tags to pre-format ourmultiline texts inside a tag. HI THERE! XMP is sweet. I don't know why such as useful tag is deprecated. XMP is sweet. I don't know why such as useful tag is deprecated. HI THERE! XMP is sweet. I don't know why such as useful tag is deprecated. My multi line content inside a paragraph <p/> tag My multi line content inside a paragraph <p/> tag All we have to do is use a CSS class as we would in any other case: For example: we could do the following:Listing 4: <xmp style="color: blue; font-weight: bold;">Content</xmp> Friday, June 15, 2007Consistent Efficiency Is KeyTask:
Short of writing the date with a string, which of the two following methods demonstrates a clear logical thought? (Disregarding the conciseness of the code). Method #1: Method #2: When seen from the biggest picture, i.e., a total development project cost (and/or tco) of $1, the two methods above demonstrate a difference between:
Subscribe to:
Posts (Atom)
|

