XML to Excel column width is not staying fixed - excel

I am converting xml to Excel via XSLT 1.0. I have assigned the columns and rows a fixed value and removed the auto adjustment of width/height.
<Column ss:StyleID="s180" ss:AutoFitWidth="0" ss:Width="112.5"/>
...
<Row ss:AutoFitHeight="0" ss:Height="15" ss:StyleID="s67">
However this doesn't seem to actually be happening. I have varying reports from users that conflict with my own machine. Of course the mysterious conversion factor from XSLT's ss:width and Excel's width applies.
Column:
User 1 - 38.09
User 2 - 20.82
My Machine - 20.74
Row:
User 1 - 14.50
User 2 - 15.15
My Machine - 15.00
I've searched as many query strings as I can think of trying to understand why the set value I have isn't being adhered to. I've even checked the page setup, but I'm not fitting to the page and the scale is a set value as well.
<FitToPage/>
<Print>
<ValidPrinterInfo/>
<Scale>71</Scale>
<HorizontalResolution>600</HorizontalResolution>
<VerticalResolution>600</VerticalResolution>
</Print>
As far as I read this the Excel document should always maintain the same width/height, but that isn't being seen when deployed.
Any help would be welcome!

Per this forum message
You are correct, column width measurement is an odd-ball in Excel. 1
increment of column width is equal to the width of the zero character of the
font used by the Normal style for a workbook. So a column of width 10 would
fit exactly 10 zero characters in the font specified by the Normal style.
So it appears you don't have complete control over what column width units mean.

Related

Excel: Set a maxium value for colour scale

I am trying to create a data analysis spreadsheet for some test results in a school.
The picture above is some dummy data I am using. I need to highlight using a colour scale conditional formatting for each question, however I want the spreadsheet to know the maximum value and minimum value from the Marks row. The minimum mark for all questions is obviously 1, however the maximum for question 1 would be 3, for question 2 it would be 2 etc.
The problem is when using the stock colour scale, say if no one achieves full marks in a question, the highest mark even though not actual maximum would be highlighted green.
Any help would be greatly appreciated.

SSRS layout and column visibility

I have about 40 columns that I need to hide/display based on certain conditions. At any given time there would not be more than 10 columns( do not know which ones) that could get displayed. I need to make sure that the report is rendered in letter paper size, though in landscape orientation. I have added all the columns to the table and have set the can grow to True. Despite it when I run the report I get the data that I want a about 2 extra blank pages. Any suggestions why those are displayed and also if there is a way to control this? The report runs off of a stored procedure.
Why don't you try to set all columns at 1mm width with CanGrow=True?

Hidden column when exporting to Excel from SSRS despite using points

Like many people, I have trouble sometimes with exporting to Excel from SSRS: hidden or split columns appear. Up to now, I have found that using multiples of 18 points works very well. However, I have found an exception to this rule.
If I create a tablix with one column 864 (12 x 72) points wide and a second column 72 points wide, I get a hidden column C. If, instead, the first column of my tablix is 936 (13 x 72) points wide, and the second column is still 72 points wide, I do not get any hidden columns.
I've looked in the .rdl file and there's nothing hidden in there like headers or footers. My page width is 210mm. I tried changing it to 150mm just to see if there was any difference but there wasn't.
Changing the second column of the first report to 73pt (so it's now 864pt and 73pt) eliminates the hidden column C. So does changing the second column to 25mm. So I may just have to fiddle with the column widths, but I would like to know why the rule of using multiples of 18 points doesn't work in this situation.
Screenshot added at the request of niktrs:
You can see that column N is hidden. It has zero width.
I found that editing the RDL file in Notepad, and towards the end of the Tablix section, changing the line <Width>330.2mm</Width> to 936pt worked. That is, there is no longer a hidden column C when exporting. As 936/72 * 25.4 = 330.2, I don't know why Report Builder didn't convert the measurement in mm to an exact number of points, but I don't mind, as I now have a report that exports correctly. I also found that right at the end of the RDL file, there is a line <rd:ReportUnitType>Mm</rd:ReportUnitType>. Changing 'Mm' to 'Point' seems to enable me to type measurements in using points and have Report Builder store them as points instead of converting them to mm.

Prevent hash signs (#) showing up in Excel without changing cell format or width

I have the following Excel VBA code:
Sheet1.Columns.ColumnWidth = 8.14
Sheet1.Rows.EntireRow.RowHeight = Sheet1.Cells(1).Width
Sheet1.Cells.WrapText = True
Sheet1.Cells.NumberFormat = "F0 P0 C0" & vbLf & "00 00 00"
Sheet1.Cells.Value = 123456789
The first two lines make the cells in my sheet perfect squares of 8.14 horizontal points and the following lines intend to make each cell look like this (aka displaying a 9 digit number in visually "separated" sections within the same cell):
F1 P2 C3
45 67 89
The problem is that Excel replaces my number (which should exactly fit into that 8.14 pts sized cell on 2 lines, since it's word-wrapped) with hash signs (#), because of its perceived length - and I don't want that.
Is there a way, through Excel settings or VBA code, to prevent this automated behavior without changing the cell format to 'General' or 'Text' or increasing the cell's width?
Now I've seen this question answered before, but all the answers referred to changing the cell format or size, which I can't do, for a couple of reasons:
this sheet is intented to be a more or less geographical "map", in which each cell is a point on that map, so naturally I need as many "points" as possible displayed in the visible section in Excel. If I make the cells (squares) larger, I can barely fit a 10x4 grid into the visible section, at 100% zoom - since I must double the cell's previous size to a huge 124 pixels, in order for Excel to display my number unaltered
if I change the format to 'Text' (aka String cell values), my Excel file becomes huge (cca. 1MB) and virtually unusable, since the map is around 255x128 "points". 255x128 number formatted cells work blisteringly fast compared to the same amount of 'text'/string formatted cells
if I change the format to 'General' is more or less the same story as above, plus, I can't use custom formats to "separate" my number sections as seen in my example (and yes, this is the intended appearance).
EDIT: While checking http://datapigtechnologies.com/blog/index.php/forcing-carriage-return-in-custom-date-format/ I found this from a certain Dave (credits to him), which is also the solution to my problem:
If you try to shrink the columnwidth, you’ll notice you’ll see ####’s way before you (or I) think you should. But a slight change can fix this. On the alignment tab of the format cell dialog, turn off wraptext (if it’s on). Turn on “shrink to fit”, then turn on wraptext.
I tried it and it worked! The VBA code for this is equally simple - adding the code below right after my initial code did the trick:
Sheet1.Cells.WrapText = False
Sheet1.Cells.ShrinkToFit = True
Sheet1.Cells.WrapText = True
I didn't want to "cheat" and answer to my own question, so I wrote this as an edit to my original post.

Excel Custom Number Format on chart Axis

I'm trying to set a Custom format for the Y-Axis of an Excel Chart and I'm not getting the result I need. I've referenced the Peltier webpage as a good source of information on creating custom Excel formats. I've come up with the following.
[>=1000000]0,,"M";[>=1000]0,"K";0
It works well until I need the rage to show values like 1 million, 1.2 million, 1.4 million, ect... I've tried
[>=1000000]0.#,,"M";[>=1000]0,"K";0
It does display 1.2M and 1.4M as needed but it has a period on the 1 million line "1. M". How do I modify my format to only show the period when the number to right of the decimal point is not zero?
So it looks like the best approach to allow the Axis to scale normally is to show a Zero on the right hand side of the decimal point, therefore always showing decimal point.
So, using
[>=1000000]0.0,,"M";[>=1000]0,"K";0
produces
800K, 1.0M, 1.2M, 1.4M, 1.6M, 1.8M, 2M, 2.2M
Without sample data together with expected results this may require some tweaking but you can add a specific circumstance to remove the decimal point. One of these might be appropriate.
[>1000000]0.0,,\M;[=1000000]0,,\M;0.0,K
[>1000999]0.0,,\M;[>999000]0,,\M;0.0,K

Resources