以俄语或其他任何语言实现错误和布尔值
Contents
[
Hide
]
可能的使用场景
如果您在俄语区域设置或语言或任何其他区域设置或语言下使用 Microsoft Excel,则它将根据该区域设置或语言显示错误和布尔值。您可以通过使用 Aspose.Cells 的 Workbook.getSettings().setGlobalizationSettings() 方法或属性来实现类似的行为。您将需要覆盖 GlobalizationSettings 类的以下方法。
以俄语或其他任何语言实现错误和布尔值
以下示例代码演示了如何在俄语或其他任何语言中实现错误和布尔值。请检查此代码中使用的示例 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(); | |
} | |
} |