以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- excel自适应宽度,怎么写语句> (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=188310) |
-- 作者:xxfoxtable -- 发布时间:2023/9/13 21:29:00 -- excel自适应宽度,怎么写语句> excel自适应宽度,怎么写语句>
[此贴子已经被作者于2023/9/13 21:31:37编辑过]
|
-- 作者:有点蓝 -- 发布时间:2023/9/14 8:42:00 -- http://www.foxtable.com/webhelp/topics/2121.htm 如果反过来,希望自动调整单元格大小,使单元格能够显示全部数据。这需要用到AutoFit方法。如:
Dim App As New MSExcel.Application Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open("D:\\Report.xls") Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1) Dim Rg As MSExcel.Range = Ws.Range("A1") Rg.Value = "Foxtable操控Excel全攻略" Rg.Font.Size = 50 \'把字体放大 Rg.EntireColumn.AutoFit \'自动调整列宽 Rg.EntireRow.AutoFit \'自动调整行高 App.Visible = True 如果要调整工作表全部单元格的大小,可以使用Cells属性。如: Dim App As New MSExcel.Application Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open("D:\\Report.xls") Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1) Dim Rg As MSExcel.Range = Ws.Cells Rg.EntireColumn.AutoFit \'自动调整列宽 Rg.EntireRow.AutoFit \'自动调整行高 App.Visible = True |