Print

Stop Excel Row Height Self-Adjust on Refresh

The Situation
I have a Microsoft Excel 2007 file that connects to a SQL Server 2008 R2 database. The Excel file pulls data using lookup tables and displays the data in an Excel Spreadsheet.

The Problem
We can select all cells and set row height to be 30 for example, but everytime we refresh the data in the Excel spreadsheet, all the rows get re-adjusted to fit the data and lose that consistency.

A Workaround: New line inserted before and after
So this is where I am at the moment without VBCode and other suggestions. Instead I add a newline in front of and after the smallest data value (one that I know will never be two lines (or two words)) within the SQL query itself. We have a DEPT column that is an acronym of the departments so for example:
copyraw
SELECT 
	Date, 
	Reservation, 
	Contact, 
	JobTitle, 
	Dept 
FROM 
	my_imaginary_table 
WHERE 
	Contact='Joe'
  1.  SELECT 
  2.      Date, 
  3.      Reservation, 
  4.      Contact, 
  5.      JobTitle, 
  6.      Dept 
  7.  FROM 
  8.      my_imaginary_table 
  9.  WHERE 
  10.      Contact='Joe' 
Would become
copyraw
SELECT 
	Date, 
	Reservation, 
	Contact, 
	JobTitle, 
	CHAR(10) + Dept + CHAR(10) AS Dept
FROM 
	my_imaginary_table 
WHERE 
	Contact='Joe'
  1.  SELECT 
  2.      Date, 
  3.      Reservation, 
  4.      Contact, 
  5.      JobTitle, 
  6.      CHAR(10) + Dept + CHAR(10) AS Dept 
  7.  FROM 
  8.      my_imaginary_table 
  9.  WHERE 
  10.      Contact='Joe' 
Now when Excel refreshes the data, it acknowledges new lines (the "CHAR(10)" as with other cell data). Quite a lot of spacing (the height of one text line), but our customers were complaining it became too convoluted and cramped when refreshing data and preferred the end result with this change.

Note on "row height":
We did not want the customer having to format the report after they've already gone through the hassle of clicking on the big fat refresh button... Keeping It Simple Silly. So the suggestion of selecting all cells and then right-clicking and selecting "row height" is beyond us. We have since simplified this so that only the person who knows how to hit the refresh button is the one to save as a PDF file and sends it to all customers. Training these people in adjusting row height would be like a magician revealing the secrets to his tricks... no it wasn't really, time was the issue.

Additional conditions
Direct access to our databases, both development and production, means that anyone with access to the Excel spreadsheet can go and view the connections and see the username/password details (granted read-only access). One of the requirements was that only authorised personnel could refresh the data on the Excel spreadsheet and they would then save as PDF and send to appropriate staff.

Other Issues
I usually felt that CHAR(13) goes hand in hand with CHAR(10) and although it displayed and printed properly, when saving as a PDF, CHAR(13) would return weird question mark symbols instead.

Bonus
All rows with this would be about 3 lines of text in height. Data with 4 lines of text would adjust their row to fit but all others were left untouched. Perfect!

Other Searches that I may search for again but get me nothing
Category: Excel :: Article: 391