Free Support Forum - aspose.com

Java Free online Excel viewer

I downloaded the latest Aspose.Cells For Java sample code, but after using gridweb, you can’t see the effect of the official website cell viewer. What if you can get the effect of Java cell viewer?

@huosenyuan,

Please elaborate your issue and give us more details and samples. Did you download the Aspose.Cells for Java examples here?
Also, what effects you are talking about? Do you mean to say Excel files are not loaded fine into GridWeb (Java) but are displayed fine into Excel viewer app? Could you share your sample Excel files, we will check it soon.

PS. For your information, Excel viewer application is written in .NET. Also, please zip the Excel files prior attaching here.

I download the Aspose.Cells for Java examples, If there is Chinese in the sample file, it will be garbled, How to deal with it?

@huosenyuan,

Could you please zip and attach the sample Excel file, we will check it soon. Moreover, please try using latest Aspose.Cells.GridWeb (Java) v21.3 (you may get it from Downloads section or from maven repos.) and let us know your feedback.

image.png (70.3 KB)
image.png (149.7 KB)
Examples.GridWeb.zip

@huosenyuan,
We are analyzing this issue and will provide our feedback once ready for sharing.

Thank you very much. I’m looking forward to hearing from you

@huosenyuan,

I did test your scenario/case in a separate web project using latest Aspose.Cells.GridWeb for Java v21.3 with its latest resource files (please use latest files in acw_client folder of Aspose.Cells.GridWeb for Java v21.3). I used a simple .jsp page having following source code. It simply imports the “chineseData.xls” file into GridWeb and it works fine.
e.g.
Sample code:

%@ page language="java" contentType="text/html; charset=UTF-8"
 import="com.aspose.gridweb.*,java.io.*" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

<%
ExtPage BeanManager=ExtPage.getInstance();
BeanManager.setServlet(request, response);
BeanManager.setPageaction( request.getContextPath()+"/GridWebServlet"); 
BeanManager.setPageajaxcallpath(request.getContextPath()+"/GridWebServlet?acw_ajax_call=true"); 
GridWebBean gridweb=BeanManager.getBean();
gridweb.setACWClientPath("../grid/acw_client/");
%>
<%@include file="/head.jsp" %>
</head>
<BODY>
<%
gridweb.setEnableAsync(true);
gridweb.setRenderHiddenRow(true);
gridweb.setWidth(Unit.Pixel(1200));
gridweb.setHeight(Unit.Pixel(600));
 String file="f:\\Files\\online excel viewer\\WebContent\\file\\chineseData.xls";

gridweb.importExcelFile(file);
 gridweb.prepareRender();
out.println(gridweb.getHTMLBody());
  %>
  <br>
 
</BODY>
</html>

I used Tomcat v7.0 server with JDK1.7 and Google chrome browser type. See the screenshot attached that shows Chinese chars are displayed fine.
Sc_shot1.png (52.3 KB)

Which browser type you are using? Please note, it does not look good in eclipse IDE editor.

I’m glad that the problem of garbled Chinese has been solved. The reasons are as follows:

This is the original code of GitHub, which has the problem of Chinese garbled code:

protected void doPost(HttpServletRequest request, HttpServletResponse response) {
try {
out = response.getWriter();
page.setServlet(request, response);
GridWebBean gridweb=page.getBean();
//we shall call it to update request and response in gridweb before render
try {
request.setCharacterEncoding(“UTF-8”);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
response.setCharacterEncoding(“UTF-8”);
path = request.getServletContext().getRealPath("/");
webPath = request.getServletContext().getContextPath();
// do the reflect method
this.process(gridweb,request, response);
gridweb.prepareRender();
String html = gridweb.getHTMLBody();
out.print(html);
// FileUtil.putFile(html);
out.flush();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e2) {
//e.printStackTrace();
out.print(e2.getMessage());
out.flush();
}finally{
out.close();
}
}

Distribution is the adjusted code, Chinese can be displayed normally, if you can, please correct the official sample code:

protected void doPost(HttpServletRequest request, HttpServletResponse response) {
try {
page.setServlet(request, response);
GridWebBean gridweb = page.getBean();
//we shall call it to update request and response in gridweb before render
try {
request.setCharacterEncoding(“UTF-8”);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
path = request.getServletContext().getRealPath("/");
webPath = request.getServletContext().getContextPath();
// do the reflect method
this.process(gridweb, request, response);
gridweb.prepareRender();
String html = gridweb.getHTMLBody();
response.setCharacterEncoding(“UTF-8”);
response.setContentType(“text/html; charset=UTF-8”);
out = response.getWriter();
out.print(html);
// FileUtil.putFile(html);
out.flush();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e2) {
//e.printStackTrace();
out.print(e2.getMessage());
out.flush();
} finally {
out.close();
}
}

New problem, array out of bounds error when clicking on other sheet pages; this problem also exists in our official sample code gridweb.
image.png (206.5 KB)

in the TestGridWebBaseServlet in method doPost
protected void doPost(HttpServletRequest request, HttpServletResponse response) {
try {//we need to put the below line at first,then the chinese char can display as normal
response.setCharacterEncoding(“UTF-8”);

the issue will not occur if you have set license .
however ,we will fix it

I really didn’t set the license. I hope I can switch the sheet page normally after setting the license

@huosenyuan,

You are right, it should work in evaluation mode and should not necessarily require the license to be set. We have logged a ticket with an id “CELLSJAVA-43437” for your issue. We will look into it soon.

Once we have an update on it, we will let you know.

@huosenyuan,

This is to inform you that we have fixed your issue (logged earlier as “CELLSJAVA-43437”) now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

thank you very much

@huosenyuan,

You are welcome.

The issues you have found earlier (filed as CELLSJAVA-43437) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi