Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Java code to convert csv into pbix

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.

 
 
1 REPLY 1
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

Based on my test, it is not supported yet currently.
You can come up a new idea about that and add your comments there to improve Power BI and make this feature coming sooner.


https://ideas.powerbi.com/forums/265200-power-bi-ideas

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.