<HTML>
<BODY>
点击下面的按钮,开始打开Excel并创建数据表
<SCRIPT LANGUAGE="VBScript">
Function CreateNamesArray()
' Create an array to set multiple values at once.
Dim saNames(5, 2)
saNames(0, 0) = "John" saNames(0, 1) = "Smith"
saNames(1, 0) = "Tom"
saNames(1, 1) = "Brown"
saNames(2, 0) = "Sue"
saNames(2, 1) = "Thomas"
saNames(3, 0) = "Jane"
saNames(3, 1) = "Jones"
saNames(4, 0) = "Adam"
saNames(4, 1) = "Johnson"
CreateNamesArray = saNames
End Function
</SCRIPT><SCRIPT LANGUAGE="JScript">
function AutomateExcel()
{ // Start Excel and get Application object.
var oXL = new ActiveXObject("Excel.Application"); oXL.Visible = true; // Get a new workbook.
var oWB = oXL.Workbooks.Add();
var oSheet = oWB.ActiveSheet; // Add table headers going cell by cell.
oSheet.Cells(1, 1).Value = "First Name";
oSheet.Cells(1, 2).Value = "Last Name";
oSheet.Cells(1, 3).Value = "Full Name";
oSheet.Cells(1, 4).Value = "Salary"; // Format A1:D1 as bold, vertical alignment = center.
oSheet.Range("A1", "D1").Font.Bold = true;
oSheet.Range("A1", "D1").VerticalAlignment = -4108; //xlVAlignCenter // Create an array to set multiple values at once. // Fill A2:B6 with an array of values (from VBScript).
oSheet.Range("A2", "B6").Value = CreateNamesArray(); // Fill C2:C6 with a relative formula (=A2 & " " & B2).
var oRng = oSheet.Range("C2", "C6");
oRng.Formula = "=A2 & \" \" & B2"; // Fill D2:D6 with a formula(=RAND()*100000) and apply format.
oRng = oSheet.Range("D2", "D6");
oRng.Formula = "=RAND()*100000";
oRng.NumberFormat = "$0.00"; // AutoFit columns A:D.
oRng = oSheet.Range("A1", "D1");
oRng.EntireColumn.AutoFit(); // Manipulate a variable number of columns for Quarterly Sales Data.
DispalyQuarterlySales(oSheet); // Make sure Excel is visible and give the user control
// of Excel's lifetime.
oXL.Visible = true;
oXL.UserControl = true;
}function DispalyQuarterlySales(oWS)
{
var iNumQtrs, sMsg, iRet; // Number of quarters to display data for.
iNumQtrs = 4; // Starting at E1, fill headers for the number of columns selected.
var oResizeRange = oWS.Range("E1", "E1").Resize(1,iNumQtrs);
oResizeRange.Formula = "=\"Q\" & COLUMN()-4 & CHAR(10) & \"Sales\""; // Change the Orientation and WrapText properties for the headers.
oResizeRange.Orientation = 38;
oResizeRange.WrapText = true; // Fill the interior color of the headers.
oResizeRange.Interior.ColorIndex = 36; // Fill the columns with a formula and apply a number format.
oResizeRange = oWS.Range("E2", "E6").Resize(5,iNumQtrs);
oResizeRange.Formula = "=RAND()*100";
oResizeRange.NumberFormat = "$0.00"; // Apply borders to the Sales data and headers.
oResizeRange = oWS.Range("E1", "E6").Resize(6,iNumQtrs);
oResizeRange.Borders.Weight = 2; // xlThin // Add a Totals formula for the sales data and apply a border.
oResizeRange = oWS.Range("E8", "E8").Resize(1,iNumQtrs);
oResizeRange.Formula = "=SUM(E2:E6)";
// 9 = xlEdgeBottom
oResizeRange.Borders(9).LineStyle = -4119; //xlDouble
oResizeRange.Borders(9).Weight = 4; //xlThick // Add a Chart for the selected data. oResizeRange = oWS.Range("E2:E6").Resize(5,iNumQtrs);
var oChart = oWS.Parent.Charts.Add();
oChart.ChartWizard(oResizeRange, -4100, null, 2); // -4100 = xl3dColumn
oChart.SeriesCollection(1).XValues = oWS.Range("A2", "A6");
for (iRet = 1; iRet <= iNumQtrs; iRet++) {
oChart.SeriesCollection(iRet).Name = "=\"Q" + iRet + "\"";
}
oChart.Location(2, oWS.Name); // 2 = xlLocationAsObject // Move the chart so as not to cover your data.
oWS.Shapes("Chart 1").Top = oWS.Rows(10).Top;
oWS.Shapes("Chart 1").Left = oWS.Columns(2).Left;
}
</SCRIPT>
<P><INPUT id=button1 type=button value="创建 Excel" onclick="AutomateExcel"></P>
</BODY>
</HTML>
<BODY>
点击下面的按钮,开始打开Excel并创建数据表
<SCRIPT LANGUAGE="VBScript">
Function CreateNamesArray()
' Create an array to set multiple values at once.
Dim saNames(5, 2)
saNames(0, 0) = "John" saNames(0, 1) = "Smith"
saNames(1, 0) = "Tom"
saNames(1, 1) = "Brown"
saNames(2, 0) = "Sue"
saNames(2, 1) = "Thomas"
saNames(3, 0) = "Jane"
saNames(3, 1) = "Jones"
saNames(4, 0) = "Adam"
saNames(4, 1) = "Johnson"
CreateNamesArray = saNames
End Function
</SCRIPT><SCRIPT LANGUAGE="JScript">
function AutomateExcel()
{ // Start Excel and get Application object.
var oXL = new ActiveXObject("Excel.Application"); oXL.Visible = true; // Get a new workbook.
var oWB = oXL.Workbooks.Add();
var oSheet = oWB.ActiveSheet; // Add table headers going cell by cell.
oSheet.Cells(1, 1).Value = "First Name";
oSheet.Cells(1, 2).Value = "Last Name";
oSheet.Cells(1, 3).Value = "Full Name";
oSheet.Cells(1, 4).Value = "Salary"; // Format A1:D1 as bold, vertical alignment = center.
oSheet.Range("A1", "D1").Font.Bold = true;
oSheet.Range("A1", "D1").VerticalAlignment = -4108; //xlVAlignCenter // Create an array to set multiple values at once. // Fill A2:B6 with an array of values (from VBScript).
oSheet.Range("A2", "B6").Value = CreateNamesArray(); // Fill C2:C6 with a relative formula (=A2 & " " & B2).
var oRng = oSheet.Range("C2", "C6");
oRng.Formula = "=A2 & \" \" & B2"; // Fill D2:D6 with a formula(=RAND()*100000) and apply format.
oRng = oSheet.Range("D2", "D6");
oRng.Formula = "=RAND()*100000";
oRng.NumberFormat = "$0.00"; // AutoFit columns A:D.
oRng = oSheet.Range("A1", "D1");
oRng.EntireColumn.AutoFit(); // Manipulate a variable number of columns for Quarterly Sales Data.
DispalyQuarterlySales(oSheet); // Make sure Excel is visible and give the user control
// of Excel's lifetime.
oXL.Visible = true;
oXL.UserControl = true;
}function DispalyQuarterlySales(oWS)
{
var iNumQtrs, sMsg, iRet; // Number of quarters to display data for.
iNumQtrs = 4; // Starting at E1, fill headers for the number of columns selected.
var oResizeRange = oWS.Range("E1", "E1").Resize(1,iNumQtrs);
oResizeRange.Formula = "=\"Q\" & COLUMN()-4 & CHAR(10) & \"Sales\""; // Change the Orientation and WrapText properties for the headers.
oResizeRange.Orientation = 38;
oResizeRange.WrapText = true; // Fill the interior color of the headers.
oResizeRange.Interior.ColorIndex = 36; // Fill the columns with a formula and apply a number format.
oResizeRange = oWS.Range("E2", "E6").Resize(5,iNumQtrs);
oResizeRange.Formula = "=RAND()*100";
oResizeRange.NumberFormat = "$0.00"; // Apply borders to the Sales data and headers.
oResizeRange = oWS.Range("E1", "E6").Resize(6,iNumQtrs);
oResizeRange.Borders.Weight = 2; // xlThin // Add a Totals formula for the sales data and apply a border.
oResizeRange = oWS.Range("E8", "E8").Resize(1,iNumQtrs);
oResizeRange.Formula = "=SUM(E2:E6)";
// 9 = xlEdgeBottom
oResizeRange.Borders(9).LineStyle = -4119; //xlDouble
oResizeRange.Borders(9).Weight = 4; //xlThick // Add a Chart for the selected data. oResizeRange = oWS.Range("E2:E6").Resize(5,iNumQtrs);
var oChart = oWS.Parent.Charts.Add();
oChart.ChartWizard(oResizeRange, -4100, null, 2); // -4100 = xl3dColumn
oChart.SeriesCollection(1).XValues = oWS.Range("A2", "A6");
for (iRet = 1; iRet <= iNumQtrs; iRet++) {
oChart.SeriesCollection(iRet).Name = "=\"Q" + iRet + "\"";
}
oChart.Location(2, oWS.Name); // 2 = xlLocationAsObject // Move the chart so as not to cover your data.
oWS.Shapes("Chart 1").Top = oWS.Rows(10).Top;
oWS.Shapes("Chart 1").Left = oWS.Columns(2).Left;
}
</SCRIPT>
<P><INPUT id=button1 type=button value="创建 Excel" onclick="AutomateExcel"></P>
</BODY>
</HTML>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
</head>
<body>
<p>
<object classid="clsid:0002E551-0000-0000-C000-000000000046" id="Spreadsheet1" codebase="http://download.microsoft.com/download/officexpstandard/owc10/2/w98nt42kme/en-us/owc10.exe">
<param name="DataType" value="XMLDATA">
<param name="XMLData" value="<?xml version="1.0"?>
<ss:Workbook xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet">
<x:ExcelWorkbook>
<x:ProtectStructure>False</x:ProtectStructure>
<x:ActiveSheet>0</x:ActiveSheet>
</x:ExcelWorkbook>
<ss:Styles>
<ss:Style ss:ID="Default">
<ss:Alignment ss:Horizontal="Automatic" ss:Rotate="0.0" ss:Vertical="Bottom"
ss:ReadingOrder="Context"/>
<ss:Borders>
</ss:Borders>
<ss:Font ss:FontName="宋体" ss:Size="11" ss:Color="Automatic" ss:Bold="0"
ss:Italic="0" ss:Underline="None"/>
<ss:Interior ss:Color="Automatic" ss:Pattern="None"/>
<ss:NumberFormat ss:Format="General"/>
<ss:Protection ss:Protected="1"/>
</ss:Style>
</ss:Styles>
<c:ComponentOptions>
<c:Label>
<c:Caption>Microsoft Office Spreadsheet</c:Caption>
</c:Label>
<c:MaxHeight>80%</c:MaxHeight>
<c:MaxWidth>80%</c:MaxWidth>
<c:NextSheetNumber>4</c:NextSheetNumber>
</c:ComponentOptions>
<x:WorkbookOptions>
<c:OWCVersion>10.0.0.2621 </c:OWCVersion>
<x:Height>7620</x:Height>
<x:Width>15240</x:Width>
</x:WorkbookOptions>
<ss:Worksheet ss:Name="Sheet1">
<x:WorksheetOptions>
<x:Selected/>
<x:ViewableRange>R1:R262144</x:ViewableRange>
<x:Selection>R1C1</x:Selection>
<x:TopRowVisible>0</x:TopRowVisible>
<x:LeftColumnVisible>0</x:LeftColumnVisible>
<x:ProtectContents>False</x:ProtectContents>
</x:WorksheetOptions>
<c:WorksheetOptions>
</c:WorksheetOptions>
<ss:Table ss:DefaultColumnWidth="54.0" ss:DefaultRowHeight="12.75">
</ss:Table>
</ss:Worksheet>
<ss:Worksheet ss:Name="Sheet2">
<x:WorksheetOptions>
<x:ViewableRange>R1:R262144</x:ViewableRange>
<x:Selection>R1C1</x:Selection>
<x:TopRowVisible>0</x:TopRowVisible>
<x:LeftColumnVisible>0</x:LeftColumnVisible>
<x:ProtectContents>False</x:ProtectContents>
</x:WorksheetOptions>
<c:WorksheetOptions>
</c:WorksheetOptions>
<ss:Table ss:DefaultColumnWidth="54.0" ss:DefaultRowHeight="12.75">
</ss:Table>
</ss:Worksheet>
<ss:Worksheet ss:Name="Sheet3">
<x:WorksheetOptions>
<x:ViewableRange>R1:R262144</x:ViewableRange>
<x:Selection>R1C1</x:Selection>
<x:TopRowVisible>0</x:TopRowVisible>
<x:LeftColumnVisible>0</x:LeftColumnVisible>
<x:ProtectContents>False</x:ProtectContents>
</x:WorksheetOptions>
<c:WorksheetOptions>
</c:WorksheetOptions>
<ss:Table ss:DefaultColumnWidth="54.0" ss:DefaultRowHeight="12.75">
</ss:Table>
</ss:Worksheet>
</ss:Workbook>
">
<param name="AllowPropertyToolbox" value="-1">
<param name="AutoFit" value="0">
<param name="Calculation" value="-4105">
<param name="Caption" value="Microsoft Office Spreadsheet">
<param name="DisplayColumnHeadings" value="-1">
<param name="DisplayGridlines" value="-1">
<param name="DisplayHorizontalScrollBar" value="-1">
<param name="DisplayOfficeLogo" value="-1">
<param name="DisplayPropertyToolbox" value="0">
<param name="DisplayRowHeadings" value="-1">
<param name="DisplayTitleBar" value="0">
<param name="DisplayToolbar" value="-1">
<param name="DisplayVerticalScrollBar" value="-1">
<param name="DisplayWorkbookTabs" value="-1">
<param name="EnableEvents" value="-1">
<param name="MaxHeight" value="80%">
<param name="MaxWidth" value="80%">
<param name="MoveAfterReturn" value="-1">
<param name="MoveAfterReturnDirection" value="-4121">
<param name="RightToLeft" value="0">
<param name="ScreenUpdating" value="-1">
<param name="EnableUndo" value="-1">
<PARAM NAME="LPKPath" VALUE="license.lpk"> <table width='100%' cellpadding='0' cellspacing='0' border='0' height='8'><tr><td bgColor='#336699' height='25' width='10%'> </td><td bgColor='#666666'width='85%'><font face='宋体' color='white' size='4'><b> 缺少 Microsoft Office Web Components</b></font></td></tr><tr><td bgColor='#cccccc' width='15'> </td><td bgColor='#cccccc' width='500px'><br> <font face='宋体' size='2'>此网页要求 Microsoft Office Web Components。<p align='center'> <a href='http://officeupdate.microsoft.com/office/redirect/10/owcsetup.asp?HelpLCID=1033'>单击此处安装 MMicrosoft Office Web Components。</a>.</p></font><p><font face='宋体' size='2'>此网页同时要求 Microsoft Internet Explorer 4.01((SP-1)或更高版本。</p><p align='center'><a href='http://www.microsoft.com/windows/ie/default.htm'> 单击此处安装最新的 Internet Explorer</a>.</font><br> </td></tr></table></object>
</p></body></html>
Runtime.getRuntime().exec(
"C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE");
Runtime.getRuntime().exec("cmd /E:ON /c start d:\\e.doc");
}catch(Exception ex)
{ }