Text to Columns
Split text in cells into multiple columns
The Text to Columns feature allows users to split text content from cells into multiple columns based on delimiters or fixed widths. This is useful for importing data, cleaning up datasets, and reformatting text.
Overview
Text to Columns functionality enables users to:
Split comma-separated values (CSV) into columns
Parse tab-delimited or space-delimited text
Split by custom delimiters
Break up formatted text (e.g., "First Last" � "First" | "Last")
Clean and restructure imported data
Basic Usage
The onSplitTextToColumns callback is provided by useSpreadsheetState and is triggered when users request to split text in cells.
import {
SpreadsheetProvider,
CanvasGrid,
} from "@rowsncolumns/spreadsheet";
import { useSpreadsheetState } from "@rowsncolumns/spreadsheet-state";
function SpreadsheetWithTextSplit() {
const {
activeCell,
activeSheetId,
selections,
onSplitTextToColumns,
// ... other state
} = useSpreadsheetState({
// configuration
});
return (
<SpreadsheetProvider>
<CanvasGrid
sheetId={activeSheetId}
activeCell={activeCell}
selections={selections}
onSplitTextToColumns={onSplitTextToColumns}
// ... other props
/>
</SpreadsheetProvider>
);
}Function Signature
How It Works
When onSplitTextToColumns is called:
The function analyzes the selected cells
Detects or prompts for a delimiter (comma, semicolon, tab, space, etc.)
Splits the text content based on the delimiter
Distributes the split values across adjacent columns
Preserves the original data structure
Example Usage
Manual Trigger
You can manually trigger text splitting from a button or menu:
Context Menu Integration
Add Text to Columns to the context menu:
Common Use Cases
Splitting Names
Split "First Last" into separate columns:
Parsing CSV Data
Split comma-separated values:
Processing Addresses
Split full addresses into components:
Complete Example
Custom Implementation
If you need custom text splitting logic, you can implement your own:
Delimiter Options
Common delimiters for text splitting:
Advanced Features
Multiple Delimiters
Split by multiple delimiters at once:
Fixed Width Splitting
Split text at fixed character positions:
Preserve Quoted Text
Don't split text within quotes:
Keyboard Shortcuts
Add a keyboard shortcut for text splitting:
Best Practices
Backup Data: Always preserve original data before splitting
Check Column Space: Ensure enough empty columns for split data
Handle Edge Cases: Account for empty cells and malformed data
Trim Whitespace: Remove leading/trailing spaces from split values
Validate Output: Verify the split operation produced expected results
Undo Support: Ensure split operations are undoable
Error Handling
Limitations
The split operation requires adjacent empty columns
Very long text may exceed column limits
Complex delimiters may require custom parsing
Large selections may impact performance
Use Cases
Data Import
Clean up imported CSV or TSV data:
Name Parsing
Split full names into first and last names:
Email Processing
Extract username and domain from emails:
Tag Parsing
Split tags or categories:
Troubleshooting
Split Not Working
Verify
onSplitTextToColumnsis passed to CanvasGridCheck that cells contain text data
Ensure there are empty columns for split data
Unexpected Results
Check delimiter selection
Verify text format (quotes, escapes, etc.)
Test with sample data first
Performance Issues
Limit selection size for large datasets
Consider batch processing for many cells
Use web workers for heavy split operations
Last updated
Was this helpful?