Save these code as "Excel.htm" (can't run on 9CBS)
======================================================== ASP < P> <% response.contentType = "Application / VND.MS-Excel"%>
VBScript:
javascript:
p>
Microsoft Excel Language Reference -MSDN (recommended!) P> lead:
Explore Ways to pass a microsoft excel file to the client side p>
Dim XclSub StartExcel () Set Xcl = CreateObject ( "Excel.Application") Xcl.Visible = true Set newBook = Xcl.Workbooks.Add newBook.Worksheets.Add newBook.Worksheets (1) .Activate newBook.Worksheets (1) .Range ("A1: B1000"). Numberformat = "0" newbook.worksheets (1) .RANGE ("A1: B1000"). Horizontalalignment = 1 'left aligned newbook.worksheets (1) .range ("A1: D1") . berge () 'merged cell NEWBOOK.WORKSHEETS (1) .RANGE ("A1: D1"). Value = "test" assignment newbook.worksheets (1) .range ("A1: D1"). HorizontalaLAlignment = 3 'Come among Newbook.worksheets (1) .Columns ("a"). ColumnWidth = 50' Settings Column Width Newbook.Worksheets (1) .ROWS (2) .rowHeight = 40 'Sets line high newbook.worksheets (1). Columnxt = true newbook.worksheets (1) .Columns ("b"). ColumnWidth = 50 Newbook.worksheets (1) .columns ("b"). WrapText = true newbook.worksheets (1) .Cells (2, 1). Interior.Colorindex = "15" set color newbook.worksheets (1) .Cells (2, 1). Borders.LineStyle = 1 'Setting Border 1 is a solid line, 2 is a broken line Newbook.worksheets (1) .Cells (3, 2) .font.name = "Verdana" newbook.worksheets (1) .Cells (3, 2) .font.italic = true newbook.work Sheets (1) .cells (3, 2). Horizontalalignment = 4 'right aligned newbook.worksheets (1) .Cells (2, 1) .value = "first column, first Cell" newbook.worksheets (1) .Cells 3,1) .value = "first column, second cell" newbook.worksheets (1) .Cells (2, 2) .value = "second column, first cell" newbook.worksheets (1) .Cells (3, 2) .value = "seond column, second cell" newbook.worksheets (1) .name = "my first worksheet" 'fname = xcl.getsaveasfilename ("testing excel extract.xls")' if fname = "
False "then 'fname =" "' end if 'newBook.SaveAs fname' file is automatically saved Testing Excel Extracting.xls 'Xcl.Application.Quit' Close Excel Set Xcl = nothingEnd SubSub StartExcel2 () Set Xcl = CreateObject (" Excel .Application ") xcl.visible = true set newbook = xcl.workbooks.add 'Add a new worksheet Newbook.worksheets (1) .activate newbook.worksheets (1) .RANGE (" A1: B1000 "). NumberFormat = "0" newbook.worksheets (1) .cells (1, 1) .value = "value1" newbook.worksheets (1) .cells (2, 1) .Value = "value2" newbook.worksheets (1) .Cells (1, 2) .value = "20" newbook.worksheets (1) .Cells (2, 2) .value = "10" newbook.worksheets (1) .Cells (3, 1) .value = "Total" newbook . Worksheets (1) .Cells (3, 2) .value = "= SUM (B1: B2)" Newbook.worksheets (1) .Cells (4, 1) .value = cint (newbook.worksheets (1) .Cells (3, 2) .value * 2) Newbook.worksheets (1) .name = "My Second Worksheet" 'Worksheet Named' Xcl.Application.quit 'Close Excel Set XCl = Nothingend Sub script>
function jStartExcel () {var xls = new ActiveXObject ( "Excel.Application"); xls.visible = true; var newBook = xls.Workbooks.Add; newBook.Worksheets.Add; newBook.Worksheets (1) .Activate; xls. ActiveWorkBook.ActiveSheet.PageSetup.Orientation = 2; xls.ActiveWorkBook.ActiveSheet.PageSetup.PaperSize = 5;. newBook.Worksheets (1) .Columns ( "A") columnwidth = 40; // set the width of column A 40px newBook. Worksheets (1) .Columns ("a"). WrapText = true; // Setting automatic wrap newbook.worksheets (1) .Columns ("b"). ColumnWidth = 50; // Set the B column width 50px newbook.worksheets (1) .Columns ("b"). WrapText = true; // Setting automatic wrap newbook.worksheets (1) .range ("a1: b1000"). Numberformat = "0"; newbook.worksheets (1) .range ("A1: B1000"). Horizontalalignment = -4131; Newbook.worksheets (1) .RANGE ("A1: B1"). Merge (); // Merge cell area A1: D1 newbook.worksheets (1) .range ("A1: B1"). Value = "my title"; // Assignment newbook.worksheets (1) .Range ("a1: b1"). Horizontalalignment = 3; // Create NEWBOOK.WORKSHEETS (1) .range ("A1: B1"). Interior.ColorIndex = 2; // Background Color Set to White Newbook.worksheets (1) .RANGE ("A1: B1"). Font.bold = true; // bold newbook.worksheets (1). Range ("A1: B1"). font.colorindex = 3; // Font is red Newbook.worksheets (1) .Cells (2, 1) .interior. Colorindex = 15; // background color newbook.worksheets (1) .cells (2, 1) .value = "second row, first column"; newbook.worksheets (1) .Cells (2, 1) .font.italic = True; newbook.worksheets (1) .Cells (2, 1) .font.bold = true; newbook.worksheets (1) .Cells (2, 2) .value = "Second Row, Second Column"; newbook.worksheets 1) .cells (3, 1) .value = "third row, first column"; newbook.worksheets (1) .Cells (3, 2) .value = "