0

I am attempting to write data from an InputStream into an Excel file. While I can do so, the data is writing to the first column there is, instead of writing to different columns. For instance, if my data was like

 Holiday Name             Date
Valentine's Day           2/14
 Christmas               12/25

Then Column B in Excel should contain the Date info, right? Instead, it's mushed together in Column A with the Holiday Name info. I was wondering if there was any way to write data to separate columns in Excel just with Java code and no plugins or imports.

  • If you need to write data that can be read by Excel and cannot use libraries for this purpose (in particular, the Apache POI library), then you will need to write to a CSV file and then have Excel import the data. – Hovercraft Full Of Eels Aug 15 '21 at 19:47
  • Okay, I see. I don't think I can do that, because the process needs to be fully automated. If I were to use the Apache POI library, which I've heard a lot about, could it write InputStreams to Excel? From what I've seen so far, it can write hard-coded values. – Emma Aug 15 '21 at 20:26
  • *Okay, I see. I don't think I can do that, because the process needs to be fully automated.* That seems to be a *non sequitur*. If you have Excel installed, a csv file should be opened automatically with that as its default application. *Instead, it's mushed together in Column A with the Holiday Name info.* Hard to comment without knowing what you're doing – g00se Aug 15 '21 at 21:31
  • When I meant fully automated, I mean that I can't open an Excel workbook and then load the data in. The code needs to be able to have Excel import the data by itself, without me needing to touch the keyboard except to run the code, of course. I can't upload images, as I don't have enough points, but, basically, all the data is being read into one column in Excel. If you don't know, Excel columns are denoted by letters. So Holiday Name should go under Column A and Date should go under Column B. But with the code I have, Holiday Name and Date are both under Column A. – Emma Aug 15 '21 at 22:22

0 Answers0