Verifica se il valore della cella inizia con un apice singolo

Contents
[ ]

Il seguente esempio di codice spiega che le stringhe come sample e ‘sample’ non possono essere differentiate con il metodo Cell.getStringValue(). Pertanto, dobbiamo usare il metodo Style.setQuotePrefix(boolean) per distinguerle.

const AsposeCells = require("aspose.cells.node");
const path = require("path");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
// Create workbook
const wb = new AsposeCells.Workbook();
// Create worksheet
const sheet = wb.getWorksheets().get(0);
// Access cell A1 and A2
const a1 = sheet.getCells().get("A1");
const a2 = sheet.getCells().get("A2");
// Add sample in A1 and sample with quote prefix in A2
a1.putValue("sample");
a2.putValue("'sample");
// Print their string values, A1 and A2 both are same
console.log("String value of A1: " + a1.getStringValue());
console.log("String value of A2: " + a2.getStringValue());
// Access styles of A1 and A2
const s1 = a1.getStyle();
const s2 = a2.getStyle();
console.log();
// Check if A1 and A2 has a quote prefix
console.log("A1 has a quote prefix: " + s1.getQuotePrefix());
console.log("A2 has a quote prefix: " + s2.getQuotePrefix());