Working with Core Cell Operations

Çekirdek Hücre İşlemleriyle Çalışma

Genel Bakış

Çekirdek hücre API’si, tiplenmiş değerleri, formül depolamayı, CellValueType aracılığıyla değer tipi denetimini ve getStringValue() aracılığıyla tutarlı bir dize temsiliyetini destekler.

Tiplenmiş Değerleri Depolama

import com.aspose.cells_foss.Cell;
import com.aspose.cells_foss.CellValueType;
import com.aspose.cells_foss.Workbook;
import com.aspose.cells_foss.Worksheet;

try (Workbook workbook = new Workbook()) {
    Worksheet sheet = workbook.getWorksheets().get(0);

    Cell a1 = sheet.getCells().get("A1");
    a1.putValue("Revenue");

    Cell b1 = sheet.getCells().get("B1");
    b1.putValue(42500.75);

    Cell c1 = sheet.getCells().get("C1");
    c1.putValue(true);

    Cell d1 = sheet.getCells().get("D1");
    d1.setFormula("=B1*1.2");

    // Type inspection
    System.out.println(a1.getType());  // STRING
    System.out.println(b1.getType());  // NUMBER
    System.out.println(c1.getType());  // BOOLEAN
    System.out.println(d1.getType());  // FORMULA

    workbook.save("typed.xlsx");
}

CellValueType Enum Değerleri

Enum DeğeriAçıklama
STRINGputValue(String) tarafından depolanan metin değeri
NUMBERputValue(int) veya putValue(double) tarafından depolanan sayısal değer
BOOLEANputValue(boolean) tarafından depolanan Boolean değeri
DATE_TIMEputValue(LocalDateTime) tarafından depolanan tarih/saat değeri
FORMULAsetFormula(String) tarafından depolanan formül dizesi
BLANKBoş hücre — hiçbir değer ayarlanmamış

String Değerlerini Alma

cell.getStringValue(), temel değer tipinden bağımsız olarak, görüntüleme
veya sonraki işleme uygun bir yerel ayar bağımsız dize döndürür:

import com.aspose.cells_foss.Cell;
import com.aspose.cells_foss.Workbook;
import com.aspose.cells_foss.Worksheet;

try (Workbook workbook = new Workbook()) {
    Worksheet sheet = workbook.getWorksheets().get(0);
    Cell b1 = sheet.getCells().get("B1");
    b1.putValue(123);
    System.out.println(b1.getStringValue());  // "123" — no decimal point
    workbook.save("string-values.xlsx");
}

Formül Depolama

import com.aspose.cells_foss.Cell;
import com.aspose.cells_foss.CellValueType;
import com.aspose.cells_foss.Workbook;
import com.aspose.cells_foss.Worksheet;

try (Workbook workbook = new Workbook()) {
    Worksheet sheet = workbook.getWorksheets().get(0);
    Cell b1 = sheet.getCells().get("B1");
    b1.putValue(100.0);
    Cell c1 = sheet.getCells().get("C1");
    c1.setFormula("=B1*1.2");
    System.out.println(c1.getType() == CellValueType.FORMULA);  // true
    workbook.save("formulas.xlsx");
}
 Türkçe