Entries Tagged as 'Tips and Tricks'

IE 8, Excel 2010 not opening content on Windows 7

ColdFusion , Gotchas , MS Office , Tips and Tricks No Comments »

Thought I'd dust the cobwebs off my blog by sharing something I came across today...

I came across an issue where a user reported that a web application was not opening Excel content they were requesting.

Basically the application was sending csv formatted text to the browser and the browser (Internet Explorer) was supposed to open this with Microsoft Excel 2010.

The template sending the content had the correct headers configured to instruct the browser to open this in Microsoft Excel and the content was valid but for some reason the new window was failing silently without promting the user to open \ save the file.  The only clue was that this was a new PC with Windows 7 and Internet Explorer 8 installed and their previous PC worked fine.

I decided to check with Firefox and voila - I was prompted to Open / Save the file.

So after diagnosing different scenarios through the code I then started looking into the settings on the PC for Internet Explorer.

Read more...

Basic HTML to Excel Formatting

ColdFusion , CSS , Default , MS Office , Tips and Tricks 4 Comments »

I've come across this before but have never thought to blog about it, simply because it was quite an easy implementation in the end-up.

If you're exporting data from an HTML table to an Excel workbook, then the following will save you some time when trying to get Microsoft Excel to format the data. and display it as you desire.

Using Microsofts own Office XML format, you can style \ format the cell data using "CSS like" syntax.

For example, if you wish to format a date column, you can simply add a style attribute with the content style='mso-number-format:"mm\/dd\/yyyy"'.  This format is pretty self explanatory, but will format a given date in the format "10/01/2011" for 10th January 2011.

<td style="mso-number-format:"mm\/dd\/yyyy">
   
 10/01/2011
</td>

If you're a stickler for seperation, like I am, you can take this further by defining CSS Rules in a stylesheet and specifying the class name in your HTML elements.

Read more...

Blog post 101 and a ColdFusion 101 Series

Best Practices , ColdFusion , Misc , Tips and Tricks No Comments »

To mark the 101st post on my Blog, and to complement my thoughts on what content I wish to publish on my blog in order to keep it current, I have decided that I will be writing some material on the following areas:

  • 101 - ColdFusion variables and scopes, to include complex and simple variable types.
  • 101 - Anatomy of a ColdFusion CFC.
  • ColdFusion by Example - A series of posts that provide examples of some of the most commonly used ColdFusion Tags and Functions grouped by type, with practical examples.
  • Syntax is easy, programming is hard.  A general guide on how to concentrate more on the actual programming side of development rather than getting caught up with the syntax!
It's a tall order, I know, and it'll take discipline in order to keep the momentum going with this, but the idea is to provide some useful output during this process e.g. code snippets \ templates along the way that can be used and altered by anyone (including me) during development.





Bookmark and Share

Microsoft TSQL and the GO Statement

Gotchas , SQL , Tips and Tricks No Comments »

Recently I was working on some SQL scripts using TSQL in SQL Server Management Studio and from force of habit I was using the "GO" statement between each of my SQL statements to seperate them.

I then started re-factoring the SQL, creating variables where I had hardcoded values etc. and placed those variable declarations at the top of the script.

After re-factoring, I executed the scipt and got an error message saying that the variable @varName was not defined? 

I checked for any typos...none.  I then started breaking down the script to see if I could isolate the issue.  When I removed the "GO" statements, the script executed without error.

It turns out that "GO" is not a TSQL statement, but rather a command that is recognised by the sqlcmd and osql utilities and SQL Server Management Studio.  These utilities interpret the "GO" statement as a signal that it should send the current batch of TSQL statements to an instance of SQL Server.  Therefore any variables declared before the last "GO" and the next will NOT be available in the current batch of statements. 

Just for fun I then copied my TSQL into a <cfquery> and when I executed this, found that the same error was thrown.

One to watch out for if you're not familiar with the true definition of the "GO" statement. 

Full details of the "GO" statement can be found here: http://msdn.microsoft.com/en-US/library/ms188037(v=SQL.90).aspx


Bookmark and Share

HTML format CFGRID column data alignment

ColdFusion , CSS , Javascript , Tips and Tricks No Comments »

I came across an issue yesterday where I wanted to control the alignment of certain columns in an HTML data grid using the ColfFusion \ ExtJS CFGRID.  At first I tried the "dataalign" and "headeralign" attributes of CFGRIDCOLUMN but after checking the docs it turns out that these are only available with grid formats applet \ flash.

Without delving into the ExtJS docs, I found a really simple method of doing this without having to write one line of Javascript.

<style type="text/css">
    .x-grid-col {text-align:right;}
    .x-grid-col-0 {text-align:left;}
    .x-grid-col-1 {text-align:left;}
</style>

 You can also update just the column headers using a similar method. 

<style type="text/css">
    .x-grid-hd {text-align:center;}       
    .x-grid-hd-0-0 {text-align:left;}      
    .x-grid-hd-0-1 {text-align:left;}
</style>

Credit goes to the following post http://www.webtrenches.com/post.cfm/quick-and-easy-column-alignment-for-cfgrid by @spraguey

Thanks!

Bookmark and Share
Powered by Mango Blog. Design and Icons by N.Design Studio
RSS Feeds