1

I have a column of words in Excel and i want to convert it to a string array, it is a long list and i can't do it manually. How can i do it?

My excel is like:

Car
House
Key
Phone
...

I want my array to be like:

"Car","House","Key","Phone",...

Thanks in advance.

10
  • 3
    Is this a one-off job or do you want to do that with many different excel files? Commented Aug 25, 2014 at 13:01
  • Do you need to do this in Java? (as noted by your tags) Commented Aug 25, 2014 at 13:02
  • 1
    Well, just use a formular like =""""&A1&"""," in the second column, then copy-paste that second column into your java source code. Commented Aug 25, 2014 at 13:05
  • 1
    Sure, just mark cell B1, press Ctrl+C, mark B2..B42, press Ctrl+V ... I guess you don't work with Excel that much?!? Commented Aug 25, 2014 at 13:08
  • 1
    Or you just drag the lower right corner (there should be a small black sqare) of B1 downwards... Commented Aug 25, 2014 at 13:10

2 Answers 2

0

Aspose.Cells for Java is your friend here. Use this code to read values of a column into a string array.

ArrayList<String> list = new ArrayList<>();

Workbook workbook = new Workbook("spreadsheet.xlsx");
Worksheet worksheet = workbook.getWorksheets().get("Sheet1");
for (Object o: worksheet.getCells().getRows()) {
    Cell cell = ((Row) o).getCellByIndex(0);
    list.add(cell.getStringValueWithoutFormat());
}

Import classes from com.aspose.cells.*. Enjoy a free temporary license for a limited time before purchasing.

Disclosure: I am a developer at Aspose.

Sign up to request clarification or add additional context in comments.

Comments

-1

Try Below mentioned link

Column to string

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.