Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
This tutorial will guide you through configuring multi-language support in your Aspose.Cells GridJs project. It covers both frontend and backend configurations.
The tutorial is based on the demo project. Please adjust it according to your actual situation.
In your frontend pages, set the interface language using the local option.
In the demo project, you need to modify the uidload.html file.
Here’s an example:
const loadNormalContext = (sheet) => {
const option = {
updateMode: 'server',
updateUrl: '/GridJs2/UpdateCell',
showToolbar: true,
mode: 'edit',
// Supported languages: en/zh/es/pt/de/ru/nl/pl
local: 'pl', // Set to Polish in this example
};
loadWithOption(jsondata, option);
};
In the backend code, you need to set the appropriate CultureInfo before processing Excel data.
In the demo project, you need to modify the Controller file.
The following methods in your controller need culture configuration:
Set region information when updating cells:
[HttpPost]
public ActionResult UpdateCell()
{
// Set culture info
CultureInfo polishCulture = new CultureInfo("pl-PL");
Thread.CurrentThread.CurrentCulture = polishCulture;
Thread.CurrentThread.CurrentUICulture = polishCulture;
string p = HttpContext.Request.Form["p"];
string uid = HttpContext.Request.Form["uid"];
GridJsWorkbook gwb = new GridJsWorkbook();
String ret = gwb.UpdateCell(p, uid);
return Content(ret, "text/plain", System.Text.Encoding.UTF8);
}
Set region information when retrieving Excel JSON:
public ActionResult DetailFileJsonWithUid(string filename, string uid)
{
// Set culture info
CultureInfo polishCulture = new CultureInfo("pl-PL");
Thread.CurrentThread.CurrentCulture = polishCulture;
Thread.CurrentThread.CurrentUICulture = polishCulture;
String file = Path.Combine(TestConfig.ListDir, filename);
GridJsWorkbook wbj = new GridJsWorkbook();
StringBuilder sb = wbj.GetJsonByUid(uid, filename);
if(sb == null)
{
Workbook wb = new Workbook(file);
wbj.ImportExcelFile(uid, wb);
sb = wbj.ExportToJsonStringBuilder(filename);
}
return Content(sb.ToString(), "text/plain", System.Text.Encoding.UTF8);
}
Set region information when streaming Excel JSON:
public ActionResult DetailStreamJsonWithUid(string filename, string uid)
{
// Set culture info
CultureInfo polishCulture = new CultureInfo("pl-PL");
Thread.CurrentThread.CurrentCulture = polishCulture;
Thread.CurrentThread.CurrentUICulture = polishCulture;
String file = Path.Combine(TestConfig.ListDir, filename);
GridJsWorkbook wbj = new GridJsWorkbook();
Response.ContentType = "application/json";
Response.Headers.Add("Content-Encoding", "gzip");
using (GZipStream gzip = new GZipStream(Response.Body, CompressionLevel.Optimal))
{
bool isdone = wbj.JsonToStreamByUid(gzip, uid, filename);
if(!isdone)
{
Workbook wb = new Workbook(file);
wbj.ImportExcelFile(uid, wb);
wbj.JsonToStream(gzip, filename);
}
}
return new EmptyResult();
}
CultureInfo must be set before processing Excel data.pl-PL), but you can change it to any other supported locale.Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.