Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active December 26, 2022 13:37
Show Gist options
  • Save aspose-com-gists/60527a892deb091dd4dc7ddf14b55bf0 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/60527a892deb091dd4dc7ddf14b55bf0 to your computer and use it in GitHub Desktop.
# Open Workbook
workbook = Workbook("workbook.xlsx")
# Access the first worksheet
worksheet = workbook.getWorksheets().get(0)
# Add people name in column A. Fast name and Last name are separated by space.
worksheet.getCells().get("A1").putValue("John Teal")
worksheet.getCells().get("A2").putValue("Peter Graham")
worksheet.getCells().get("A3").putValue("Brady Cortez")
worksheet.getCells().get("A4").putValue("Mack Nick")
worksheet.getCells().get("A5").putValue("Hsu Lee")
# Create text load options with space as separator.
txtLoadOptions = TxtLoadOptions()
txtLoadOptions.setSeparator(' ')
# Split the column A into two columns using TextToColumns() method.
# Now column A will have first name and column B will have second name.
worksheet.getCells().textToColumns(0, 0, 5, txtLoadOptions)
# Save the excel file.
workbook.save("TextToColumns.xlsx")
@aspose-com-gists
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment