---
title: "excel中sheet.cells的参数都是从1开始的"
author: "fourfire"
date: "2007-08-27T17:06:42Z"
tags: []
slug: "excel-sheet-cells-1"
draft: false
lastmod: "2007-08-27T17:06:42Z"
id: 117217
url: "https://fourfire.iteye.com/blog/117217"
---

用jcom获得excel cell的值  
xlsApp = new IDispatch(rm, "Excel.Application");

            xlsApp.put("Visible", new Boolean(false));  
            IDispatch workbooks = (IDispatch) xlsApp.get("Workbooks");

            workbooks.method("open", new Object\[] { file, null, null, null,  
                    password });// open  
            logger.debug("1----" + file);

            IDispatch sheets = ((IDispatch) xlsApp.get("Sheets"));

            IDispatch sheet = ((IDispatch) sheets.get("item",  
                    new Object\[] { sheetName }));  
             
            // sheet.method("Select", null);  
            IDispatch range = ((IDispatch) sheet.get("Cells", new Object\[] {  
                    new Integer(i), new Integer(j) }));  
            retval = range.get("value").toString();

i------1+；  
j-----1+；  
要是传个0就报错了