欢迎来到天天文库
浏览记录
ID:38763453
大小:28.00 KB
页数:4页
时间:2019-06-19
《js导出excel表格格式》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、1.创建实例并创建工作表varXLObj=newActiveXObject("Excel.Application");//创建Excel实例varxlBook=XLObj.Workbooks.Add;//新增工作簿varExcelSheet=xlBook.Worksheets(1);//创建工作表2.保存表格ExcelSheet.SaveAs("C:\TEST.XLS");3.使Excel通过Application对象可见ExcelSheet.Application.Visible=true;或者ExcelSheet.Visible=
2、true;4.打印xlBook.PrintOut;或者:ExcelSheet.PrintOut;5.关闭xlBook.Close(savechanges=false);或者ExcelSheet.Close(savechanges=false);6.结束进程ExcelSheet.Application.Quit()或者XLObj.Quit();XLObj=null;7.页面设置ExcelSheet.ActiveSheet.PageSetup.LeftMargin=2/0.035;//页边距左2厘米ExcelSheet.ActiveShee
3、t.PageSetup.RightMargin=3/0.035;//页边距右3厘米,ExcelSheet.ActiveSheet.PageSetup.TopMargin=4/0.035;//页边距上4厘米,ExcelSheet.ActiveSheet.PageSetup.BottomMargin=5/0.035;//页边距下5厘米ExcelSheet.ActiveSheet.PageSetup.HeaderMargin=1/0.035;//页边距页眉1厘米ExcelSheet.ActiveSheet.PageSetup.FooterMa
4、rgin=2/0.035;//页边距页脚2厘米ExcelSheet.ActiveSheet.PageSetup.CenterHeader="页眉中部内容";ExcelSheet.ActiveSheet.PageSetup.LeftHeader="页眉左部内容";ExcelSheet.ActiveSheet.PageSetup.RightHeader="页眉右部内容";ExcelSheet.ActiveSheet.PageSetup.CenterFooter="页脚中部内容";ExcelSheet.ActiveSheet.PageSetu
5、p.LeftFooter="页脚左部内容";ExcelSheet.ActiveSheet.PageSetup.RightFooter="页脚右部内容";8.对单元格操作,带*部分对于行,列,区域都有相应属性ExcelSheet.ActiveSheet.Cells(row,col).Value="内容";//设置单元格内容ExcelSheet.ActiveSheet.Cells(row,col).Borders.Weight=1;//设置单元格边框*()ExcelSheet.ActiveSheet.Cells(row,col).Inter
6、ior.ColorIndex=1;//设置单元格底色*(1-黑色,2-白色,3-红色,4-绿色,5-蓝色,6-黄色,7-粉红色,8-天蓝色,9-酱土色..可以多做尝试)ExcelSheet.ActiveSheet.Cells(row,col).Interior.Pattern=1;//设置单元格背景样式*(1-无,2-细网格,3-粗网格,4-斑点,5-横线,6-竖线..可以多做尝试)ExcelSheet.ActiveSheet.Cells(row,col).Font.ColorIndex=1;//设置字体颜色*(与上相同)ExcelSh
7、eet.ActiveSheet.Cells(row,col).Font.Size=10;//设置为10号字*ExcelSheet.ActiveSheet.Cells(row,col).Font.Name="黑体";//设置为黑体*ExcelSheet.ActiveSheet.Cells(row,col).Font.Italic=true;//设置为斜体*ExcelSheet.ActiveSheet.Cells(row,col).Font.Bold=true;//设置为粗体*ExcelSheet.ActiveSheet.Cells(row
8、,col).ClearContents;//清除内容*ExcelSheet.ActiveSheet.Cells(row,col).WrapText=true;//设置为自动换行*ExcelSheet.Act
此文档下载收益归作者所有