Processing Ajax...

Title

Message

Confirm

Confirm

Confirm

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure?

Excel Cells to Separate Entries

Description
This macro takes the copied Excel cells from the clipboard and creates separate ClipboardFusion history entries for each cell.
Language
C#.net
Minimum Version
Created By
Thomas Malloch (BFS)
Contributors
-
Date Created
Jan 14, 2022
Date Last Modified
Jan 14, 2022

Macro Code

using System;
using System.Collections.Generic;

// The 'text' parameter will contain the text from the:
//   - Current Clipboard when run by HotKey
//   - History Item when run from the History Menu
// The returned string will be:
//   - Placed directly on the Clipboard when run as a Macro
//   - Ignored by ClipboardFusion if it is 'null'
//   - Passed along to the next action in a Trigger (null changed to an empty string)
public static class ClipboardFusionHelper
{
	public static string ProcessText(string text)
	{
		// Clean up line breaks
		text = text.Replace(Environment.NewLine, "\n")
				.Replace("\0", "")
				.Replace("\r", "");

		// Get the lines from the text
		string[] lines = text.Split(new [] {'\n'});
		
		// Reverse the order of the lines so that they appear in the right order in this History
		Array.Reverse(lines);
		
		// Loop through the lines and add the cells to the History		
		foreach(string line in lines)
		{
			string[] cells = line.Split(new [] { '\t' });
			Array.Reverse(cells);
			foreach(string cell in cells)
				BFS.ClipboardFusion.AddHistoryText(cell);
		}
		
		// Tell ClipboardFusion to ignore the result of this macro
		return null;
	}
}