SoFunction
Updated on 2025-04-10

javascript EXCEL operation class code


ExcelOperation = function(){
= null;
= null;
= null;
= 0; //Total number of records
= null;
= 2; //The current line
/**
* Get the total number of records in the EXCEL table
*/
= function(){
//("C1").Sort(("C"),xlAscending);
var rowsCount = ;
return rowsCount;
}
/**
* Sort by specified column
* @param column column name, such as "C"
*/
= function(column){
var xlAscending = 1;
var xlYes = 1;
var xlSortRows=1;
var xlPinYin= 1;
var xlSortNormal =1;
((column),
xlAscending,null,null,null,null,null,xlYes,null,null,
xlSortRows,xlPinYin,xlSortNormal,null,null);
}
/**
* Open an EXCEL
*/
= function(fileName){
= fileName;
if(){
try{
= new ActiveXObject("");
= (fileName);
//"e:\\"
(1).select();
= ;
= ();
}catch(e){
if()
();
({
title: 'Error prompt',
msg: 'Please check the following settings of your system: 1,'+
'Whether the EXCEL in OFFICE is correctly installed; 2, correctly set
Set your IE browser ('+
'Tools->Internet Options->Security->Internet->Custom
Meaning level->'+
'Enable "On ActiveX controls that are not marked as secure..."
);3, Is the data file deleted?
buttons : ,
icon :
});
return false;
}
}else{
({
title: 'Error prompt',
msg: 'Please select the source data file to import!',
buttons : ,
icon :
});
return false;
}
return ;
}
/**
* Read data of the specified cell,
*/
= function(row,col){
var data = (row,col).Value;
if(typeof data == 'undefined')
return '';
else
return data;
}
/**
* Write data to the specified cell
*/
= function(row,col,data){
(row,col) = data
}
/**
* Close EXCEL
*/
= function(){
= false;
();
= null;
=null;
=null;
CollectGarbage();
}
}