ロシア語またはその他の言語でエラーとブール値を実装する
Contents
[
Hide
]
考えられる使用シナリオ
ロシア語のロケールまたは言語、またはその他のロケールまたは言語で Microsoft Excel を使用している場合、そのロケールまたは言語に従ってエラーとブール値が表示されます。 Aspose.Cells を使用して同様の動作を実現できますWorkbook.getSettings().setGlobalizationSettings()メソッドまたはプロパティ。次のメソッドをオーバーライドする必要がありますグローバリゼーション設定クラス。
ロシア語またはその他の言語でエラーとブール値を実装する
次のサンプル コードは、ロシア語またはその他の言語でエラーとブール値を実装する方法を示しています。このコードで使用されているサンプル Excel ファイルとその出力 PDF を確認してください。スクリーンショットは、サンプル Excel ファイルそしてその出力 PDF参考までに。
サンプルコード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
public class ImplementErrorsAndBooleanValueInRussianOrAnyOtherLanguage { | |
// Russian Globalization | |
class RussianGlobalization extends GlobalizationSettings { | |
public String getErrorValueString(String err) { | |
switch (err.toUpperCase()) { | |
case "#NAME?": | |
return "#RussianName-имя?"; | |
} | |
return "RussianError-ошибка"; | |
} | |
public String getBooleanValueString(Boolean bv) { | |
return bv ? "RussianTrue-правда" : "RussianFalse-ложный"; | |
} | |
} | |
public void Run() throws Exception { | |
System.out.println("Aspose.Cells for Java Version: " + CellsHelper.getVersion()); | |
String srcDir = Utils.Get_SourceDirectory(); | |
String outDir = Utils.Get_OutputDirectory(); | |
// Load the source workbook | |
Workbook wb = new Workbook(srcDir + "sampleRussianGlobalization.xlsx"); | |
// Set GlobalizationSettings in Russian Language | |
wb.getSettings().setGlobalizationSettings(new RussianGlobalization()); | |
// Calculate the formula | |
wb.calculateFormula(); | |
// Save the workbook in pdf format | |
wb.save(outDir + "outputRussianGlobalization.pdf"); | |
} | |
public static void main(String[] args) throws Exception { | |
ImplementErrorsAndBooleanValueInRussianOrAnyOtherLanguage impErr = new ImplementErrorsAndBooleanValueInRussianOrAnyOtherLanguage(); | |
impErr.Run(); | |
} | |
} |