>  기사  >  웹 프론트엔드  >  javascript EXCEL 연산 코드_javascript 기술

javascript EXCEL 연산 코드_javascript 기술

WBOY
WBOY원래의
2016-05-16 18:49:04934검색
复제대码 代码如下:

ExcelOperation = function(){
this.oXL = null;
this.oWB = null;
this.oSheet = null;
this.xlsRowCount = 0; //总记录数
this.excelFileName = null;
this.currentRow = 2; //전행
/**
* EXCEL 테이블의 총 레코드 수를 가져옵니다
*/
this.getRowCount = function(){
//oSheet.Range("C1").Sort(oSheet.Columns("C") ,xl오름차순);
varrowCount = this.oSheet.UsedRange.Cells.Rows.Count;
rowCount를 반환합니다.
}
/**
* 지정된 열을 기준으로 정렬
* @param 열 "C"와 같은 열 이름
*/
this.sort = function(column){
var xlAscending = 1;
var xlYes = 1;
var xlSortRows=1;
var xlPinYin= 1;
var xlSortNormal =1;
this.oSheet.UsedRange.Sort(this.oSheet.Columns(열),
xlAscending,null,null,null,null,null,xlYes,null,null,
xlSortRows,xlPinYin,xlSortNormal, 널,널);
}
/**
* EXCEL을 엽니다
*/
this.openExcel = function(fileName){
this.fileName = fileName;
if(this.fileName){
try{
this.oXL = new ActiveXObject("Excel.application");
this.oWB = this.oXL.Workbooks.open(파일 이름);
//"e:\join.xls"
this.oWB.worksheets(1).select();
this.oSheet = this.oWB.ActiveSheet;
this.xlsRowCount = this.getRowCount();
}catch(e){
if(this.oXL)
this.closeExcel(); 置您的IE浏览器('
'工具->internet选项->보안->인터넷->자정
义级别->'
'启용“对没有标记为안전한ActiveX控件...”
);3,数据文件是否被删除',
버튼 : Ext.Msg.OK,
아이콘 : Ext. 메시지 오류
});
거짓을 반환합니다.
}
}else{
Ext.Msg.show({
title : '错误提示',
msg : '请选择要导入的源数据文件!',
버튼 : Ext.Msg.OK,
아이콘 : Ext.Msg.ERROR
});
거짓을 반환합니다.
}
return this.oSheet;
}
/**
* 지정된 셀의 데이터를 읽어옵니다.
*/
this.readData = function(row,col){
var data = this.oSheet.Cells(row,col).Value;
if(데이터 유형 == '정의되지 않음')
return '';
그렇지 않으면
데이터를 반환합니다.
}
/**
* 지정된 셀에 데이터 쓰기
*/
this.writeData = function(row,col,data){
this.oSheet.Cells(row,col) = data
}
/**
* EXCEL 닫기
*/
this.closeExcel = function(){
this.oXL.DisplayAlerts = false;
this.oXL.Quit();
this.oXL = null;
this.oWB=null;
this.oSheet=null;
쓰레기 수집();
}
}

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.