Hi,
HTML is well.
Hi,
xValue are double but not datetime.This chart’s CategoryData is Date.
2. point’s xValue, yValue, xPx and yPx are wrong, because in chart points sort by first column, not according table dataWhen chart save to image, MS Excel and Aspose.Cells sort points by CategoryData.But series.getPoints return points without sort, and they have wrong position!
OK. The xlsx above is too complex.
+ point.getShapeYPx() + “…” + point.getShapeHeightPx());
Hi,
- CELLSJAVA-42043 - Chart points positions are wrong
In fact I hope Aspose.Cells fix this issue that without change NSeries.points order. I just want Aspose.Cells return correct chart point position.
xhaixia:
In fact I hope Aspose.Cells fix this issue that without change NSeries.points order. I just want Aspose.Cells return correct chart point position.
xhaixia:
In 2nd issue, I know I can convert double to DateTime.But I hope Aspose.Cells return DateTime with getXValue()In my case, I can't determine which type of xValue because XLSX files are uploaded by end user.
Hi,
- CELLSJAVA-42046 - Aspose.Cells should return DateTime values instead of double values with getXValue() method
Main:
public static void Test1380() throws Exception{
String dir = "D:\\Aspose\\User\\1380\\";
Workbook wb = new Workbook(dir + "日期-数值-EXCEL联合图(有问题)555.xlsx");
Chart chart = wb.getWorksheets().get(0).getCharts().get(0);
chart.calculate();
Series series = chart.getNSeries().get(0);
System.out.println(series.getDisplayName());
ChartPointCollection points = series.getPoints();
int pointCount = points.getCount();
ArrayList listChartPoints = new ArrayList();
for (int i = 0; i < pointCount; i++) {
ChartPoint point = points.get(i);
MyChartPoint myChartPoint = new MyChartPoint(point);
listChartPoints.add(myChartPoint);
}
Collections.sort(listChartPoints);
for (int i = 0; i < listChartPoints.size(); i++) {
MyChartPoint myChartPoint = (MyChartPoint)listChartPoints.get(i);
ChartPoint point = myChartPoint.getChartPoint();
double OADate = Double.parseDouble(point.getXValue().toString());
System.out.println(OADate);
Date date = fromDoubleToDateTime(OADate);
SimpleDateFormat sf=new SimpleDateFormat("M/d/yyyy");
System.out.println(sf.format(date)+ "==>" + point.getYValue()
+ "::::" + point.getShapeXPx() + "@" + point.getShapeYPx());
}
}
public static Date fromDoubleToDateTime(double OADate)
{
long num = (long) ((OADate * 86400000.0) + ((OADate >= 0.0) ? 0.5 : -0.5));
if (num < 0L) {
num -= (num % 0x5265c00L) * 2L;
}
num += 0x3680b5e1fc00L;
num -= 62135596800000L;
return new Date(num);
}
MyChartPoint.cs:
import com.aspose.cells.ChartPoint;
public class MyChartPoint implements Comparable
{
private ChartPoint m_chartPoint;
public MyChartPoint(ChartPoint p){
m_chartPoint = p;
}
public ChartPoint getChartPoint(){
return this.m_chartPoint;
}
@Override
public int compareTo(Object o) {
MyChartPoint other = (MyChartPoint)o;
Object thisObject = this.getChartPoint().getXValue();
Object otherObject = other.getChartPoint().getXValue();
if(thisObject == null && otherObject == null){
return 0;
}
else if(thisObject != null && otherObject == null){
return 1;
}
else if(thisObject == null && otherObject != null){
return -1;
}
double thisXvalue = Double.parseDouble(thisObject.toString());
double otherXvalue = Double.parseDouble(otherObject.toString());
if ( thisXvalue== otherXvalue)
{
return 0;
}
else if (thisXvalue > otherXvalue)
{
return 1;
}
else
{
return -1;
}
}
}
Hi,
Hi,
the following sample code with the new fix.
public static void Test1380() throws Exception{
String dir = "D:\\Aspose\\User\\1380\\";
Workbook wb = new Workbook(dir + "日期-数值-EXCEL联合图(有问题)555.xlsx");
Chart chart = wb.getWorksheets().get(0).getCharts().get(0);
//chart.toImage(dir + “chart.png”);<o:p></o:p>
chart.calculate();
Series series = chart.getNSeries().get(0);
System.out.println(series.getDisplayName());<o:p></o:p>
ChartPointCollection points = series.getPoints();<o:p></o:p>
int pointCount = points.getCount();
ArrayList listChartPoints = new ArrayList();
for (int i = 0; i < pointCount; i++) {
ChartPoint point = points.get(i);<o:p></o:p>
MyChartPoint myChartPoint = new MyChartPoint(point);<o:p></o:p>
listChartPoints.add(myChartPoint);<o:p></o:p>
}
Collections.sort(listChartPoints);
for (int i = 0; i < listChartPoints.size(); i++) {
MyChartPoint myChartPoint = (MyChartPoint)listChartPoints.get(i);<o:p></o:p>
ChartPoint point = myChartPoint.getChartPoint();<o:p></o:p>
double OADate = Double.parseDouble(point.getXValue().toString());<o:p></o:p>
System.out.println(OADate);
Date date = fromDoubleToDateTime(OADate);
SimpleDateFormat sf=new SimpleDateFormat(“M/d/yyyy”); <o:p></o:p>
System.out.println(sf.format(date)+ "==>" + point.getYValue()
+ "::::" + point.getShapeXPx() + "@" + point.getShapeYPx());
<o:p></o:p>
}
}
public static Date fromDoubleToDateTime(double OADate)
{
long num = (long) ((OADate * 86400000.0) + ((OADate >= 0.0) ? 0.5 : -0.5));
if (num < 0L) {
num -= (num % 0x5265c00L) * 2L;
}
num += 0x3680b5e1fc00L;
num -= 62135596800000L;
return new Date(num);
}
public class MyChartPoint implements Comparable
{
private ChartPoint m_chartPoint;
public MyChartPoint(ChartPoint p){
m_chartPoint = p;
}
public ChartPoint getChartPoint(){
return this.m_chartPoint;
}
@Override
public int compareTo(Object o) {
MyChartPoint other = (MyChartPoint)o;
Object thisObject = this.getChartPoint().getXValue();
Object otherObject = other.getChartPoint().getXValue();
if(thisObject == null && otherObject == null){
return 0;
}
else if(thisObject != null && otherObject == null){
return 1;
}
else if(thisObject == null && otherObject != null){
return -1;
}
double thisXvalue = Double.parseDouble(thisObject.toString());
double otherXvalue = Double.parseDouble(otherObject.toString());
if ( thisXvalue== otherXvalue)
{
return 0;
}
else if (thisXvalue > otherXvalue)
{
return 1;
}
else
{
return -1;
}
}
}
Let us know your feedback.
Thank you.
The issues you have found earlier (filed as CELLSJAVA-42043) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.