CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VB >  基础类

再问excel表格问题

楼主ljqqyx()2005-11-29 12:45:25 在 VB / 基础类 提问

请问怎样在导出数据的excel表中设置行、宽和字体 问题点数:40、回复次数:7Top

1 楼vbman2003(家人)回复于 2005-11-29 12:50:47 得分 0

你在EXCEL中把你想设置的操作一遍,同时录下操作过程的宏。然后按ctrl+F11看看模块中的代码就有了Top

2 楼faysky2(出来混,迟早是要还嘀)回复于 2005-11-29 13:09:10 得分 40

设置指定列的宽度(单位:字符个数)  
   
    eole.ActiveSheet.Columns(1).ColumnWidth=5  
   
  设置指定行的高度(单位:磅)  
   
    eole.ActiveSheet.Rows(1).RowHeight=1/0.035Top

3 楼faysky2(出来混,迟早是要还嘀)回复于 2005-11-29 13:10:40 得分 0

设置字体  
   
    eole.ActiveSheet.Cells(2,1).Font.Name=″黑体″  
   
  设置字体大小  
   
    eole.ActiveSheet.Cells(1,1).Font.Size=25  
   
  设置字体为斜体  
   
    eole.ActiveSheet.Cells(1,1).Font.Italic=.t.  
   
  设置整列字体为粗体  
   
    eole.ActiveSheet.Columns(1).Font.Bold=.t.  
   
  Top

4 楼ljqqyx()回复于 2005-11-29 13:12:43 得分 0

Dim   xlApp   As   New   Excel.Application  
                          Dim   xlBook   As   Excel.Workbook  
                          Dim   xlSheet   As   Excel.Worksheet  
                          Dim   i,   j   As   Integer  
                          Dim   a   As   Excel.CellFormat  
                   
                          Screen.MousePointer   =   11  
   
                          Set   xlApp   =   CreateObject("Excel.Application")  
                          Set   xlBook   =   Nothing  
                          Set   xlSheet   =   Nothing  
                          Set   xlBook   =   xlApp.Workbooks().Add  
                          Set   xlSheet   =   xlBook.Worksheets("sheet1")  
                          i   =   0  
                      xlSheet.Cells(1,   (mfgContent.Cols   \   2)).Value   =   mfgContent.TextMatrix(1,   1)  
                          For   i   =   0   To   mfgContent.Rows   -   1  
                                  For   j   =   0   To   mfgContent.Cols  
                                          xlSheet.Cells(i   +   2,   j).Value   =   mfgContent.TextMatrix(i,   j   +   1)  
                                  Next   j  
                          Next   i  
                          With   ActiveWorkbook  
                                  .SaveAs   App.Path   &   "\excel.xls"  
                          End   With  
                          xlApp.Visible   =   False  
                          xlApp.Application.Visible   =   False  
                          Set   xlApp   =   Nothing  
                          Set   xlBook   =   Nothing  
                          Set   xlSheet   =   Nothing  
                          Screen.MousePointer   =   0  
  请高手指点一下,怎么在上面的代码中实现我的要求!!!谢谢!!!  
  Top

5 楼faysky2(出来混,迟早是要还嘀)回复于 2005-11-29 14:12:07 得分 0

Dim   xlApp   As   New   Excel.Application  
                          Dim   xlBook   As   Excel.Workbook  
                          Dim   xlSheet   As   Excel.Worksheet  
                          Dim   i,   j   As   Integer  
                          Dim   a   As   Excel.CellFormat  
                   
                          Screen.MousePointer   =   11  
   
                          Set   xlApp   =   CreateObject("Excel.Application")  
                          Set   xlBook   =   Nothing  
                          Set   xlSheet   =   Nothing  
                          Set   xlBook   =   xlApp.Workbooks().Add  
                          Set   xlSheet   =   xlBook.Worksheets("sheet1")  
                          i   =   0  
                          xlSheet.Cells(1,   (mfgContent.Cols   \   2)).Value   =   mfgContent.TextMatrix(1,   1)  
                          For   i   =   0   To   mfgContent.Rows   -   1  
                                  xlSheet.Columns(i+2).ColumnWidth   =   11.25   '设置列宽  
                                  xlSheet.Columns(i+2).Font.Name   =   "黑体"  
                                  For   j   =   0   To   mfgContent.Cols  
                                          If   j=0   Then   xlSheet.Rows(j).RowHeight   =   30.75   '设置行高  
                                          xlSheet.cells(i   +   2,   j).Font.Name   =   "黑体"   '设置字体  
                                          xlSheet.cells(i   +   2,   j).Font.Size=18     '设置字体大小  
                                          xlSheet.Cells(i   +   2,   j).Value   =   mfgContent.TextMatrix(i,   j   +   1)  
                                  Next   j  
                          Next   i  
                          With   ActiveWorkbook  
                                  .SaveAs   App.Path   &   "\excel.xls"  
                          End   With  
                          xlApp.Visible   =   False  
                          xlApp.Application.Visible   =   False  
                          Set   xlApp   =   Nothing  
                          Set   xlBook   =   Nothing  
                          Set   xlSheet   =   Nothing  
                          Screen.MousePointer   =   0  
  Top

6 楼ljqqyx()回复于 2005-11-29 14:28:16 得分 0

faysky20:  
      高手,在请教一下,怎样给导出的表加边框!!  
                                                              谢谢!!!!!  
   
   
  Top

7 楼faysky2(出来混,迟早是要还嘀)回复于 2005-11-29 14:33:03 得分 0

'边框范围不合适的话,自己修改  
  j=mfgContent.Cols  
  '       画边框-------------------------------------------------  
          xlSheet.Range("a"   &   "2",   "i"   &   j).Font.Size   =   11  
          xlSheet.Range("A"   &   "5",   "I"   &   j).Borders(xlEdgeLeft).LineStyle   =   xlContinuous  
          xlSheet.Range("A"   &   "5",   "I"   &   j).Borders(xlEdgeLeft).Weight   =   xlThin  
          xlSheet.Range("A"   &   "5",   "I"   &   j).Borders(xlEdgeLeft).ColorIndex   =   xlAutomatic  
          xlSheet.Range("A"   &   "5",   "I"   &   j).Borders(xlEdgeTop).LineStyle   =   xlContinuous  
          xlSheet.Range("A"   &   "5",   "I"   &   j).Borders(xlEdgeTop).Weight   =   xlThin  
          xlSheet.Range("A"   &   "5",   "I"   &   j).Borders(xlEdgeTop).ColorIndex   =   xlAutomatic  
          xlSheet.Range("A"   &   "5",   "I"   &   j).Borders(xlEdgeBottom).LineStyle   =   xlContinuous  
          xlSheet.Range("A"   &   "5",   "I"   &   j).Borders(xlEdgeBottom).Weight   =   xlThin  
          xlSheet.Range("A"   &   "5",   "I"   &   j).Borders(xlEdgeBottom).ColorIndex   =   xlAutomatic  
          xlSheet.Range("A"   &   "5",   "I"   &   j).Borders(xlEdgeRight).LineStyle   =   xlContinuous  
          xlSheet.Range("A"   &   "5",   "I"   &   j).Borders(xlEdgeRight).Weight   =   xlThin  
          xlSheet.Range("A"   &   "5",   "I"   &   j).Borders(xlEdgeRight).ColorIndex   =   xlAutomatic  
          xlSheet.Range("A"   &   "5",   "I"   &   j).Borders(xlInsideVertical).LineStyle   =   xlContinuous  
          xlSheet.Range("A"   &   "5",   "I"   &   j).Borders(xlInsideVertical).Weight   =   xlThin  
          xlSheet.Range("A"   &   "5",   "I"   &   j).Borders(xlInsideVertical).ColorIndex   =   xlAutomaticTop

相关问题

  • 读取Excel表格问题
  • 急!!!excel表格
  • excel表格
  • 高分请教EXCEL表格问题
  • 小妹?^_^?捉虫:excel表格的问题?
  • 有关EXCEL表格单位问题
  • VB生成Excel表格的问题
  • 关于Excel表格复制的问题??
  • PB导为EXCEL表格问题
  • 导出表格到excel的问题

关键词

  • 字体
  • excel
  • xlsheet
  • mfgcontent
  • xlbook
  • xlapp
  • xlcontinuous
  • eole
  • 设置
  • activesheet

得分解答快速导航

  • 帖主:ljqqyx
  • faysky2

相关链接

  • Visual Basic类图书
  • Visual Basic类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo