主题:  Copy HTML File毗ExcelWorkShee々

cjalex

职务:普通成员
等级:1
金币:0.0
发贴:2
注册:2003/3/5 14:31:36
#12003/3/5 14:33:51
请兜称疤·恰部蝗脱CFScript Copy HTML File毗ExcelWorkSheets泼年弄Sheet々
叉裁进糠Sheet喇根。芒谯恕 Copy HTML毗糠Sheet惧。身Code。
TestExcel.cfm
DIRECTORY="D:\htdocs\Lehman\test\"
FILENAME="test"
SHEETNAME="22"
LEAVEOPEN="NO"
>
test


HTML2Excel.cfm












































ACTION="CONNECT"
CLASS="Excel.Application"
NAME="objExcel"
TYPE="COM">





ACTION="CREATE"
CLASS="Excel.Application"
NAME="objExcel"
TYPE="COM">










// open Excel in the background
objExcel.Visible = false;

// disable Alerts such as: 'Save this workbook?'
objExcel.DisplayAlerts =false;
// Define the workbooks object
objWorkBook = objExcel.Workbooks;
objWorkBook1=objWorkBook.Open("D:\htdocs\Lehman\Test\test3.xls");
objSheets1 = objWorkBook1.WorkSheets;
objSheet1 = objSheets1.Add();
objSheet1.Name ="newtest";

// open the Excel file */
objWorkBook2 = objWorkBook.Open(HTMLFilePath);
objSheets2 = objWorkBook2.WorkSheets;
// get the active worksheet - will have the same name as the HTML file
objSheet2 =objSheets2.Item(HTMLFileName);
objSheet1=objSheets1.Item(val(1));
objSheet1=objSheet2.copy();
// Save As does not work with workbooks / only with worksheets
objWorkBook1.save();
// Close the document
objWorkBook1.Close();
if(Attributes.LeaveOpen IS "No"){
// Quit Excel
objExcel.Quit();
}
//release the object
objExcel = "Nothing";




objExcel.Quit();



















 
Error: This tag requires an end tag!!
Usage:

Dynamically generated HTML to convert to MS Excel format



Problems? Contact the author at: pstolz@usa.net




wait

职务:普通成员
等级:1
金币:10.0
发贴:220
注册:2002/10/19 11:02:36
#22003/3/6 7:30:22
呵呵,这下可以省很多时间了。不过用的机会肯定也不多。