ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Controlling column widths in interactive web page output (https://www.excelbanter.com/excel-discussion-misc-queries/122778-controlling-column-widths-interactive-web-page-output.html)

Chris Collingridge

Controlling column widths in interactive web page output
 
Hi,

Apology: Already posted in excel.worksheet.functions a few days ago, but
think this may be more appropriate location. Apologies if you're reading it
twice.

I'm having an issue with column widths when generating an interactive HTML
page from an Excel sheet. Basically, although the columns are set up with
the proper widths in Excel (and these widths are respected when generating
static HTML) they appear narrower when the interactive web version is
displayed.

I can't find anything about this problem anywhere in the help, the web, or
on newsgroups, but it seems to me as though the proportions of the columns
are staying the same - it's that the web view (because of the big useless
white border - any suggestions on that welcome) is smaller so the columns
become narrower.

I need my columns to stay the width they're set up as in Excel. Is there any
way to explicitly set pixel values for column width for exporting to
interactive HTML? Or any other way around the problem?

Thanks,
Chris



JMay

Controlling column widths in interactive web page output
 
As a last resort, with no other options you might try something like the
following. I wrote it to autofit my sheet PLUS to add 3 additional
spaces
at the end to have it look a bit more unbuntched.

Sub AutoFitPlus3Spaces()
Dim LCol As Long
Dim CurrCol As Range
Dim MyCol As Integer
Dim Dcol As String
Dim i As Integer
ActiveCell.SpecialCells(xlLastCell).Select
LCol = Selection.Column
MyCol = LCol + 64
Dcol = Chr(MyCol)
Application.Range("A:" & Dcol).Columns.AutoFit
For i = 1 To LCol
Set myrng = Range(Cells(1, i), Cells(Rows.Count, i))
If Application.WorksheetFunction.CountA(myrng) 0 Then
Columns(i).ColumnWidth = Int(Columns(i).ColumnWidth) + 3 'change
to suit
End If
Next i
End Sub

HTH,
Jim May


"Chris Collingridge" wrote in
message :

Hi,

Apology: Already posted in excel.worksheet.functions a few days ago, but
think this may be more appropriate location. Apologies if you're reading it
twice.

I'm having an issue with column widths when generating an interactive HTML
page from an Excel sheet. Basically, although the columns are set up with
the proper widths in Excel (and these widths are respected when generating
static HTML) they appear narrower when the interactive web version is
displayed.

I can't find anything about this problem anywhere in the help, the web, or
on newsgroups, but it seems to me as though the proportions of the columns
are staying the same - it's that the web view (because of the big useless
white border - any suggestions on that welcome) is smaller so the columns
become narrower.

I need my columns to stay the width they're set up as in Excel. Is there any
way to explicitly set pixel values for column width for exporting to
interactive HTML? Or any other way around the problem?

Thanks,
Chris




All times are GMT +1. The time now is 02:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com