Showing posts with label stupid. Show all posts
Showing posts with label stupid. Show all posts

Sunday, April 18, 2010

How to create an Excel file programmatically (Part 1)

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.

  1. The should've-been-the-easy-way: (X)HTML+CSS+Excel Formula minus-JavaScript format saved as .xls file.
  2. The should've-been-just-as-easy-way: Office 2003 XML format saved as .xls file.
  3. 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.

<!--xml version="1.0" ...?--> <!--DOCTYPE html PUBLIC "... XHTML 1.0 Strict//EN"... --> <html> <head> <title>XHTML-based Excel file</title> <style>/*CSS styling directives here*/</style> </head> <body> <table> <tr> <td>This is Cell A1 in Excel</td> <td>This is Cell B1 in Excel</td> </tr> <tr> <td>123</td> <td>456</td> <td>=A2+B2</td> </tr> </table> </body> </html>

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

<table>, <tr>, <td> 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: XHTML-based Excel file warning dialog be enough to make us try to think of a new, more "Excel-worthy" technique? I certainly thought so.

Up next (Part 2): Office 2003 XML format approach.

Saturday, September 06, 2008

Confidence == Self.Comfort in {Knowns, Unknowns}

Confidence != Perfection;

Confidence != Arrogance.Hide(Inferiority);

What do we do when a user asks for a facility for a matter of convenience and where the cost of providing such convenience far outweighs the value of the time saved from the convenience?

There's a dictum that states: "Customer is King." If we want to be responsible subjects to our king, it is our duties to say to the King: "Your Majesty, if you wear this 'clothes' you will be naked; is that what you really want?" and instead of: "Yes Your Majesty, we will use the finest invisible silk thread to match the invisible royal garb you ordered."

Friday, April 11, 2008

Joy is...

A smile in spite of what's around.

You know... these days I sensed a lot of unhappiness around me—not from me, mind you—around me. So I took a few minutes out of my day and scoured the Internet to see if I could find some quick, inspirational statements people say about how we can reach happiness since I don't seem to be doing well in inspiring happiness for others.

Here's what I found:

From Dennis Wholey:
Quote #1: Happy people plan actions, they don't plan results.
Quote #2: Expecting the world to treat you fairly because you are a good person is a little like expecting a bull not to attack you because you are a vegetarian.

Here's another from our favorite genius, Albert Einstein:
Quote #3: If you want to live a happy life, tie it to a goal, not to people or things.

From an unknown smartie:
Quote #4: Happiness is not the absence of problems but the ability to deal with them.
Quote #5: Some pursue happiness; others create it.

How are these useful for me? Eeh, they aren't new to me, really; they're what I already naturally use for me. And I'm happy in a happy-go-lucky-sort-of-way-kind-of-guy; see if these could be as useful for you as they have been for me.

Thursday, January 17, 2008

What a great {insert a nerdy title here} feels:

  • I don't need to prove I'm 1337 to know I am one.
  • I don't understand the end-user, but I'll always try to.
  • My end-user is the reason I have a job.
  • Patience really is a virtue.
  • Nobody likes complicated stuff.
  • It's better to be perceived as inexperienced but a quick study, than experienced but a slow poke.
  • Knowing the subject well is better than knowing how to code well.
  • If I don't know how to code it well, give it to someone who does, then learn from it.
  • $1/day for 365 days is better than $10 for only 30 days. Long term builds trust, character and wealth; short one brings false sense of confidence.
  • Each new job feels like my first job; done with great excitement, else it could be my last one.
  • Get completely in or get out, capiche?