[]
        
首页
开发者学堂
文档
论坛
市场
生态机会
活动
立即试用
(Showing Draft Content)

CellInfo

Class CellInfo

java.lang.Object
com.grapecity.documents.excel.CellInfo

public final class CellInfo extends Object
提供用于在单元格地址与行/列索引之间转换的辅助函数。

此实用工具类提供静态方法,用于将行索引转换为名称、将列索引转换为名称、将单元格索引转换为地址,以及执行反向转换。它还支持获取给定区域的像素边界。


 // Convert cell index (row=2, column=1) to name -> "B3"
 String cellName = CellInfo.CellIndexToName(2, 1);
 
 // Convert cell name to index -> [2, 1]
 int[] index = CellInfo.CellNameToIndex("B3");
 
 // Convert column index to name -> "D"
 String colName = CellInfo.ColumnIndexToName(3);
 
 // Convert row index to name -> "5"
 String rowName = CellInfo.RowIndexToName(4);
 
  • Constructor Details

    • CellInfo

      public CellInfo()
  • Method Details

    • RowIndexToName

      public static String RowIndexToName(int index)
      根据行索引获取行名称。
      
       String rowName = CellInfo.RowIndexToName(4);
       
      Parameters:
      index - 行索引
      Returns:
      行的名称
    • RowNameToIndex

      public static int RowNameToIndex(String name)
      根据行名称获取行索引。
      
       int rowIndex = CellInfo.RowNameToIndex("5");
       
      Parameters:
      name - 行名称
      Returns:
      行的索引
    • ColumnIndexToName

      public static String ColumnIndexToName(int index)
      根据列索引获取列名称。
      
       String columnName = CellInfo.ColumnIndexToName(3);
       
      Parameters:
      index - 列索引
      Returns:
      列的名称
    • ColumnNameToIndex

      public static int ColumnNameToIndex(String name)
      根据列名称获取列索引。
      
       int columnIndex = CellInfo.ColumnNameToIndex("D");
       
      Parameters:
      name - 列名称
      Returns:
      列的索引
    • CellIndexToName

      public static String CellIndexToName(int row, int column)
      根据单元格的行索引和列索引获取单元格名称(地址)。
      
       String cellName = CellInfo.CellIndexToName(2, 1);
       
      Parameters:
      row - 行索引
      column - 列索引
      Returns:
      单元格的地址
    • CellNameToIndex

      public static int[] CellNameToIndex(String name)
      根据单元格名称(地址)获取单元格的行和列。
      
       int[] index = CellInfo.CellNameToIndex("B3");
       
      Parameters:
      name - 单元格名称
      Returns:
      包含转换后的行索引和列索引的数组
    • GetRangeBoundary

      public static Rectangle GetRangeBoundary(IRange range)
      获取指定区域的位置和大小(以像素为单位)。
      
       Rectangle boundary = CellInfo.GetRangeBoundary(worksheet.getRange("A1:B2"));
       
      Parameters:
      range - Range 对象
      Returns:
      包含该区域位置和大小的矩形