Apache poi sparklines - apache-poi

there is a "new" feature in Excel 2010 called sparklines. I could not find something about it regarding Apache POI. It looks like Apache POI does not support this feature. Am I right ?
Looks like this:
https://goo.gl/djnQSX
Thanks a lot!

You are completely right!
The Apache POI library has no support for SparkLines or other kind of chart as it's explained in their limitations page.
However if you just want to change/read/write the data behind the chart you can use POI anyway.
If you want or need something else like change the style or the range with chart data, it's no so hard to make some code to manage this kind of graphs.
Just by doing the next:
Change the extension of the Excel file from 'xlsx' to 'zip'
Unzip the file content.
Identify the number of the Sheet where your Sparkline is by editing the file 'xl/workbook.xml' and looking for a text similar to: ""
Then edit the file with that sheet info ('xl/worksheets/sheet3.xml' in the example).
Look for the code of the SparkLines (usally at the end of the file). It should looks like this:
<ext uri="{05C60535-1F16-4fd2-B633-F4F36F0B64E0}" xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main">
<x14:sparklineGroups xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
<x14:sparklineGroup displayEmptyCellsAs="gap">
<x14:colorSeries theme="4" tint="-0.499984740745262"/>
<x14:colorNegative theme="5"/>
<x14:colorAxis rgb="FF000000"/>
<x14:colorMarkers theme="4" tint="-0.499984740745262"/>
<x14:colorFirst theme="4" tint="0.39997558519241921"/>
<x14:colorLast theme="4" tint="0.39997558519241921"/>
<x14:colorHigh theme="4"/>
<x14:colorLow theme="4"/>
<x14:sparklines>
<x14:sparkline>
<xm:f>Sheet3!A2:A25</xm:f>
<xm:sqref>B3</xm:sqref>
</x14:sparkline>
</x14:sparklines>
</x14:sparklineGroup>
</x14:sparklineGroups>
</ext>
There you can edit the style info and data of the sparkline chart as you want/need.
Save the changes.
Compress again with ZIP all the folders and files.
Change the extension to 'xlsx' again.
You can do all this tasks with code.
I hope this helps

Related

XSSFWorkbook.setActiveSheet() equivalent in JasperReports?

We're using JasperReports 6.13.0 to generate XLSX format reports. We have a requirement where we need to show a particular sheet as default visible(instead of the first sheet) whenever the user opens the generated XLSX report.
My question is, do we have this feature in JasperReports? I couldn't find anything related to it in the documentation.
Note: In Apache POI, we can achieve this functionality using: XSSFWorkbook.setActiveSheet(int index)
JasperReports doesn't currently include this feature.
You can consider patching the JasperReports code to add it. What you would need to do is to add something like the following line in XlsxWorkbookHelper.exportHeader after the line with workbookPr.
write("<bookViews><workbookView activeTab=\"" + activeSheet + "\"/></bookViews>\\n");
You'd also need to pass the active sheet index somehow from the exporter.
Alternatively, you can export to XLSX using JasperReports and then open the file with POI and set the active sheet.

Domino Designer: Export a view to CSV File using formula language

In Domino Designer, I would like to export a view to CSV file, with the details as per below:
Select all document
In UTF-8
Include Column Title
I tried to use formula language to at least export it to csv, and save it at the current user's desktop, but it seems like %UserProfile% is not working.
#Command([FileExport];"Comma Separated Value";"C:\Users\%UserProfile%\Desktop\temp.csv")
I have tried to change "%UserProfile%" with Public, and it works, but preferably I wish it could be done using current user profile.
My questions are:
Can I use formula language to code something like this?
Is there any lotusscript similar to my description as above (i.e The CSV file can be exported only by one click?
Thank you in advance.
No
Yes, see example as a starting point.

How to import a segment of html into Excel

Requirement:
1.I need to export a table as a excel file.
2.I render it in a html page at first. I have a button to export to html.
My opinion:
1.I get the html from page:
document.getElementById('content').value = document.getElementById('containerId').innerHTML;
form1.submit();
2.I get it from server, response.ContentType = "application/vnd.ms-excel;" // it need the client has installed Microsoft Excel.
3.I got the right Excel file "XXXX.xls".
4.BUT BUT BUT, when I open it, it's alert a waring tell me like
"it's not the right format of Excel, are you confirm to open it?"
I'm feel sorry to see it.
So I want to import the HTML section into a Excel file, then response the right Excel file to USER-AGENT.
I have use the Aspose.Cells library in my project, I don't know how to use it to finish the task, Or is any other solution to solve it ?
If you need to parse html tags/portion to Excel spreadsheet using Aspose.Cells for .NET, you may use Cell.HtmlString attribute to set your desired html code segment in a cell, it will be parsed accordingly in the generated Excel file. Mind you, not all the html tags are supported at the moment.
Aspose.Cells for .NET also supports to convert an Excel file to Html file directly, see the documents on which file formats are supported for conversion, it may help you for your reference:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/opening-files.html
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/saving-files.html
If you still have some issue/confusion, kindly give us details with your sample code using Aspose.Cells API, we can help you.

SQLite data into Excel?

I wish to pull data from a large SQLite database into Excel. I'll want to do so quite interactively so don't want to export CSVs or anything like that. I have seen the sqliteodbc website on ch-werner.de but does that work with Excel 2007?
What are the best options?
Actually I have gone through the ch-werner.de file mentioned in the question and it works well, even in Excel 2007. Simply make sure to register your database using the ODBC option in the Windows control panel.
Excel recognizes XML and the format is something like this:-
<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\" xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:html=\"http://www.w3.org/TR/REC-html40\">
<DocumentProperties xmlns=\"urn:schemas-microsoft-com:office:office\">
You might want to create a sample of the output you want in Excel, save it as XML data. Open your regular text edit, and voila... you got the XML skeleton.
Now programmatically converting SQLite to Excel, that's another thing. You didn't mention what language you're conversant with.

How to read an Open Office spreadsheet?

How can I read an Open Office 3.0 spreadsheet (.ods) from Groovy? I'd like to select specific columns from a named worksheet. Ideally, it would be useful to add a 'where' clause, or other criteria clause.
I've never used it, but Open Office has a Java API, which of course you could use from Groovy as well. It looks like the best places to start reading are the Developer's Guide, the Java UNO Reference, and the samples in Java and (hey!) Groovy. Hope that helps!
Might be something here at Spring Factories or here at Groovy and JMX. There is a forum for Groovy and Open Office.
Could you export the table / spreadsheet as SQL entries then use that. You could also look at this plugin for goovy -- http://www.ifcx.org/
OpenOffice documents are ZIP files which contains the document data as XML plus some other files (style sheets for word documents). Details can be found here.
The main problem with calc is formulas. If you just have tabular data, then you can simply read the cell values and use that. So you can open the ZIP archive, read the content.xml in it and parse that with any XML parser.
But when a cell contains a formula, then you need to execute it. In this case, you will have to open the document via the UNO API. Here is the Java version. There is a link where you can download example code that explains how to open ODF documents and how to examine their content. There are also snippets but none of them show how to examine a sheet.
The main disadvantage of UNO is the documentation. Each method is explained somewhere but you have to find the method which solves your problem, first.
Since the title does not mention Groovy (only question specifics does), I didn't want to make this a new question.
How to generally read an Open Office spreadsheet document? There are tools for creating one (ooo-python) but not for reading one. They are XML but just bluntly diving into that and trying to get the right logic of extracting the data I want seems so sub-optimal.
What I'd like is features similar to Excel COM support, but from a command line tool (or scripting language).

Resources