0

Am using androidplot library to display dynamic/static charts & graphs within my Android app. But now I have to export those charts/graphs into excel formats. AndroidPlot library is not providing any API to export the charts/graphs. Is there anyway to do the same?

Can anybody please help me or let me know some workaround to deal with this issue.

1 Answers1

0

That is not a built-in feature of Androidplot however it should be trivial to write a method to suit your needs. All you would need to do is iterate over the XYSeries and write each x/y value to a file separated by a comma. This gives you a generic CSV formatted file that Excel can open. Whether the values or interleaved in or series, how many series are contained in a single file etc, is up to you. To get you started, here's a simple routine that will convert a single XYSeries to an interleaved CSV string. All that's left to do is write the String to file:

/**
 * Converts an XYSeries into CSV "x,y,x,y..." format.
 * @param series The series to be converted.
 * @return CSV formatted version of series.
 */
String toCsv(XYSeries series) {
    StringBuffer output = new StringBuffer();
    for(int i = 0; i < series.size(); i++) {
        output.append(series.getX(i).toString());
        output.append(',');
        output.append(series.getY(i)).toString();
    }
    return output.toString();
}
Nick
  • 8,181
  • 4
  • 38
  • 63
  • Hi Nick, Thanks for your post. I appreciate your help. Let me implement the same by following your guidance. – BDeveloper Jun 03 '14 at 08:16