Sha256: b56ec3748586d6f477ff21a3caae3531c2ebe040317cb1fa41a05eb893a6c672

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

/**
 * Sencha GXT 3.1.1 - Sencha for GWT
 * Copyright(c) 2007-2014, Sencha, Inc.
 * licensing@sencha.com
 *
 * http://www.sencha.com/products/gxt/license/
 */
package com.dldinternet.aws.cfn.stacker.desktopapp.client.spreadsheet;

public class SpreadsheetUtilities {

  public static String getCellName(int rowIndex, int columnIndex) {
    return getCellName(rowIndex, getColumnName(columnIndex));
  }

  public static String getCellName(int rowIndex, String columnName) {
    return getCellName(Integer.toString(rowIndex + 1), columnName);
  }

  public static String getCellName(String rowName, int columnIndex) {
    return getCellName(rowName, getColumnName(columnIndex));
  }

  public static String getCellName(String rowName, String columnName) {
    return columnName + rowName;
  }

  public static int getColumnIndex(String columnName) {
    int columnIndex = -1;
    int length = columnName.length();
    for (int i = 0; i < length; i++) {
      char c = columnName.charAt(i);
      if ('a' <= c && c <= 'z') {
        c -= 'a' - 'A';
      }
      columnIndex = ((columnIndex + 1) * 26) + c - 'A';
    }
    return columnIndex;
  }

  public static String getColumnName(int columnIndex) {
    boolean moreDigits = true;
    StringBuilder s = new StringBuilder();
    while (moreDigits) {
      int remainder = columnIndex % 26;
      columnIndex /= 26;
      char c = (char) ('A' + remainder);
      s.insert(0, c);
      moreDigits = columnIndex > 0;
      columnIndex--;
    }
    return s.toString();
  }

}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aws-cfn-stacker-0.0.6 ui/src/com/dldinternet/aws/cfn/stacker/desktopapp/client/spreadsheet/SpreadsheetUtilities.java