`
samsongbest
  • 浏览: 171355 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

excel 处理 by JS

 
阅读更多

js 处理 excel

 

<html>
<script type = "text/javascript">  
    function init() {  
        //alert("Hello World!!!");  
    }  


    </script>  
<body onload=init()> 
<script type = "text/javascript"> 
var oXL = new ActiveXObject("Excel.Application");  
var oWB = oXL.Workbooks.open("D:/excel_JS/es.xlsx"); 
oWB.worksheets(1).select(); 
var oSheet1 = oWB.ActiveSheet; 
oWB.worksheets(2).select(); 
var oSheet2 = oWB.ActiveSheet; 


var sheet1_row =oWB.Worksheets(1).UsedRange.Cells.Rows.Count; 
var sheet1_col =oWB.Worksheets(1).UsedRange.Columns.Count; 
 
var sheet2_row =oWB.Worksheets(2).UsedRange.Cells.Rows.Count; 
var sheet2_col =oWB.Worksheets(2).UsedRange.Columns.Count; 
 

try { 
	for (var j=1;j<=sheet2_row;j++) { 

		for(var x = 1; x <= sheet1_row; x++) {
			if (oSheet1.Cells(x,1).value == oSheet2.Cells(j,1).value) {
				document.write(oSheet1.Cells(x,2).value + " ");
				document.write("<br/>"); 
			}

		}

	} 
} 
catch(e) 
{ 
    oWB.close(); 
} 
oWB.close();
   </script> 

</body>
</html>

 

 

2

 

<html>
<script type = "text/javascript">  
    function init() {  
        //alert("Hello World!!!");  
    }  
function deal() {
	

var oXL = new ActiveXObject("Excel.Application");  
var oWB = oXL.Workbooks.open(document .getElementById("ifile").value); 
oWB.worksheets(1).select(); 
var oSheet1 = oWB.ActiveSheet; 
oWB.worksheets(2).select(); 
var oSheet2 = oWB.ActiveSheet; 


var sheet1_row =oWB.Worksheets(1).UsedRange.Cells.Rows.Count; 
var sheet1_col =oWB.Worksheets(1).UsedRange.Columns.Count; 
 
var sheet2_row =oWB.Worksheets(2).UsedRange.Cells.Rows.Count; 
var sheet2_col =oWB.Worksheets(2).UsedRange.Columns.Count; 
 

try { 
	for (var j=1;j<=sheet2_row;j++) { 

		for(var x = 1; x <= sheet1_row; x++) {
			if (oSheet1.Cells(x,1).value == oSheet2.Cells(j,1).value) {
				document.write(oSheet1.Cells(x,2).value + " ");
				document.write("<br/>"); 
			}

		}

	} 
} 
catch(e) 
{ 
    oWB.close(); 
} 
oWB.close();




}

    </script>  
<body onload=init()> 

请选择需要处理的文件: <input id  = ifile type="file">

<input onclick = deal(); type = button value=处理>
<br/>
<br/>

<script type = "text/javascript"> 

   </script> 
<div id = cc></div>

</body>
</html>

 3.html

<html>  
<script type = "text/javascript">    
//this function is owned by Sam Song <samsongbest@163.com> 12/23/2014 


function deal() {  

  
var oXL = new ActiveXObject("Excel.Application");    
var oWB = oXL.Workbooks.open(document.getElementById("ifile").value);   
oWB.worksheets(1).select();   
var oSheet1 = oWB.ActiveSheet;   
oWB.worksheets(2).select();   
var oSheet2 = oWB.ActiveSheet;   
  
  
var sheet1_row =oWB.Worksheets(1).UsedRange.Cells.Rows.Count;   
var sheet1_col =oWB.Worksheets(1).UsedRange.Columns.Count;   
   
var sheet2_row =oWB.Worksheets(2).UsedRange.Cells.Rows.Count;   
var sheet2_col =oWB.Worksheets(2).UsedRange.Columns.Count;   
   var counter=0;
  	
	document.write("Results:");document.write("<br/>");
	document.write("-------------------------------");
		document.write("<br/>");
try {   
    for (var j=1;j<=sheet2_row;j++) {   
  
        for(var x = 1; x <= sheet1_row; x++) {  
            if (oSheet1.Cells(x,1).value == oSheet2.Cells(j,1).value) {  
                document.write(oSheet1.Cells(x,2).value + " ");  
                document.write("<br/>");   
				counter++;
            }  
  
        }  
  
    }   
	counter--;
	document.write("<br/>");
	document.write("-------------------------------");
		document.write("<br/>");
	document.write("Total:" + counter);
	document.write("<br/>");
}   
catch(e)   
{   alert(e.toString());
    oWB.close();   
	
}   
oWB.close();  
  
  
  
}  
  
    </script>    
<body>   
  
Please select the Excel file: <input id  = ifile type="file">  <br> 
<label style="font-size:13px">
Note: <br>

1. This tool can query matreials by sequence numbers. <br>
2. The first sheet is data source, the sequence number should be in first column. <br>
3. The second sheet is query condition, the sequence number should be in first column. <br>
 
</label>
 <br>

<input onclick = deal() type = button value=Query>  
<br/>  
<br/>  
<label style="font-size:14px">
Following below instructions to enable ActiveX in your computer:<br/> 
1. To help protect your security, Interner Explorer has restricted this webpage from running scripts 
   <br> 
   &nbsp;&nbsp;&nbsp;or ActiveX controls that could access our computer. Click here for options...<br/> 
2. Click yellow warning bar<br/> 
3. Allow Blocked Content...<br/> 
4. Click Yes<br/> 
5. After browse excel file and click Query button. Below warning message will popup.<br/> 
&nbsp;&nbsp;&nbsp;An ActiveX control on this page might be unsafe to interact with other parts of the page. <br/> 
&nbsp;&nbsp;&nbsp;Do you want to allow this interaction?<br/> 
6. Click Yes
</label>
<br/> 
</body>  
</html> 

 

分享到:
评论

相关推荐

    js统计excel表格程序

    this script is using javascript, you can use it just by IE browser! it uses to do the statistics automatically. It supports two ways to work: 1.Input one excel, output the result of the amount about...

    Node的Excel模块ExcelJS.zip

    ExcelJS 是一个 Node.js 模块,可用来读写和操作 XLSX 和 JSON 电子表格数据和样式。示例代码:// Add column headers and define column keys and widths // Note: these column structures are a...

    T+三大财务报表打开提示powered by grapecity spreadjs

    SpreadJS是一款强大的JavaScript电子表格库,它提供了类似于Excel的功能,允许用户在Web应用中创建、编辑和显示复杂的表格数据。通过集成SpreadJS,T+软件能够提供高度交互、功能丰富的财务报表界面,使得用户可以...

    Nodejs技巧之Exceljs表格操作用法示例

    通过这些功能,你可以构建出复杂的Excel报表,并在Node.js服务端进行处理。 总结一下,Exceljs是一个强大且灵活的Node.js库,它提供了创建、读取和修改Excel文件所需的所有工具。通过其丰富的API,你可以轻松地处理...

    多个excel导出压缩成zip 文件 数据量大导出

    - 并行处理:如果系统资源允许,可以使用多线程或多进程同时处理多个Excel文件的导出和压缩,以提高整体效率。 - 存储优化:考虑使用云存储或分布式文件系统,如Hadoop HDFS,来处理和存储大数据量。 6. **安全性...

    导入excel,自动到到excel文件

    &lt;SCRIPT LANGUAGE="javascript"&gt; &lt;!-- function AutomateExcel() { // Start Excel and get Application object. var oXL = new ActiveXObject("Excel.Application"); //var oXL = new ActiveXObject("Word....

    sql行转列合并GrideView单元格 实现类似Excel效果

    为了实现Excel般的功能,开发者可能需要自定义GrideView的列定义、事件处理和样式设置。 4. **模拟Excel效果**:为了使Web应用的数据显示更接近Excel,开发者需要考虑诸如条件格式化(根据数据值改变单元格颜色)、...

    python excel操作指南

    Python在Excel操作方面的强大能力使得它成为数据处理和分析的重要工具。本文主要介绍如何使用Python进行Excel文件的读写操作,特别关注`xlrd`和`xlwt`这两个库的使用,以及在Abaqus环境下如何结合Python实例操作...

    如何读写EXCEL xls文件

    - SheetJS:JavaScript库,能在浏览器环境中读写Excel文件,包括XLS格式。 接下来,我们将以Python为例,介绍基本的读写操作: **读取XLS文件**: ```python import xlrd # 打开文件 workbook = xlrd.open_...

    EXCEL 表格模拟

    在编程环境中模拟这些功能,我们可以使用Microsoft提供的API,如Microsoft Office Interop库,或者使用开源库,如Python的pandas和openpyxl,Java的Apache POI,JavaScript的SheetJS等。 1. **数据输入与读取**: ...

    SBY.rar_sby

    4. **样例数据**:如果SBY是一个数据分析工具,可能会有CSV、Excel或数据库文件,展示如何使用SBY进行数据处理和分析。 5. **样式文件**:如果是网页或UI设计,可能有CSS、HTML或Sketch文件,显示SBY套件的界面样式...

    NTKO OFFICE文档控件JavaScript编程指南

    下面是一些基本的示例,用于展示如何使用JavaScript操作Word和Excel文档: - **Word文档插入文本**:在Word文档的当前光标位置插入一段文本。 ```javascript TANGER_OCX_OBJ.ActiveDocument.Application....

    Python读取Excel数据并生成图表过程解析

    Echarts是一个轻量级且功能强大的JavaScript图表库,它允许我们轻松地在网页上展示复杂的数据可视化。 首先,我们需要引入必要的Python库。`pyecharts`是Python的Echarts接口,用于生成Echarts图表;`xlrd`用于读取...

    matlab导入excel代码-utl_calculating_rolling_3_month_skewness_of_prices_by_s

    matlab导入excel代码utl_calculating_rolling_3_month_skewness_of_prices_by_stock utl_calculating_rolling_3_month_skewness_of_stock_prices_by_stock。关键字:sas sql join合并大数据分析宏oracle teradata ...

    matlab导入excel代码-utl_permutations_of_pairs_using_unique_values_by_group:

    matlab导入excel代码utl_permutations_of_pairs_using_unique_values_by_group 按组使用唯一值的对的排列。 关键字:sas sql join合并大数据分析宏oracle teradata mysql sas社区stackoverflow statistics人工智慧AI...

    matlab导入excel代码-utl_splitting_a_five_column_sas_dataset_by_the_median_i

    matlab导入excel代码utl_splitting_a_five_column_sas_dataset_by_the_median_into_lower_and_upper_dataset 通过中位数将五列SAS数据集分为上下数据集关键字:sas sql join合并大数据分析宏oracle teradata mysql ...

Global site tag (gtag.js) - Google Analytics