We need a Java code which automatically converts csv files into pbix files, so they can be opened and further worked on in the PowerBI Desktop. Now, I know PowerBI offers this super cool feature, which converts csv files and many other formats into pbix. However, we need a function which automatically converts the reports stored in our database directly into pbix, so that no intermediate files need to be created and stored somewhere.
We have already been able to develop a function with three parameters: The first one corresponds to the selected report, from our database; the second corresponds to the directory, in which the converted report should be generated; and finally the third parameter is the converted output file itself. The two first parameters work well and the code is able to generate a copy of any report in our database into any directory we select. However, it is able to generate csv files only. Any other format will have the same size as the csv and therefore won't be able to open.
This is what we've tried so far for the conversion part of the code:
Util.writeFile("C:\\" + "test.csv", byteString);
The above piece of code works just fine, however csv is not what we wanted.
Util.writeFile("C:\\" + "test.pbix", byteString); Util.writeFile("C:\\" + "test.pdf", byteString); Util.writeFile("C:\\" + "test.xlsx", byteString);
Each of the three lines above generates one file in the indicated format, however each of the generated files are just as large as its corresponding csv(but should be much larger) and therefore are unable to open.
File file = new File("C:\\" + "test1.csv"); File file2 = new File("C:\\" + "test1.pbix"); fileFile file2 = new File("C:\\" + "test1.pbix");.renameTo(file2);
The above piece of code does not generate any file at all, but I thought it could be worth mentioning it, as it doesn't throw any exception at all either.
P.S. We know pbix files are like zip files composed of many xml and other format files. But we don't have a clue of how to convert a single file into multiple files and how each of those files should look like.
P.S.2 The first piece of code uses objects of a class (sailpoint.tools.Util) which is apparently only available for those who have access to Sailpoint.