Excel Paste繁體中文Excel Paste 是 Visual Studio 延伸模組,可將從 Excel、Google 試算表或其他表格工具複製的儲存格內容,直接轉換成 C# 字串集合宣告並插入程式碼編輯器。 功能
支援版本
Visual Studio 2019 與 Visual Studio 2022/2026 使用不同的 VSIX 套件,請安裝符合目前 Visual Studio 版本的套件。 使用方式1. 從試算表複製資料在 Excel、Google 試算表或其他支援表格複製的工具中,選取一個或多個儲存格後執行複製。 例如複製以下內容:
Excel Paste 會依照 Tab 與換行,自動將所有儲存格整理成一維集合。 2. 回到 Visual Studio 程式碼編輯器開啟要插入程式碼的 例如:
3. 在程式碼編輯器中按滑鼠右鍵請在 Visual Studio 的「程式碼編輯區域」內按滑鼠右鍵。 右鍵選單中會出現 Excel Paste 提供的貼上功能。 從選單中選擇需要的 C# 集合型別,例如:
選擇後,Excel Paste 會讀取目前剪貼簿中的試算表內容,立即轉換並插入到目前游標位置。 例如選擇:
會產生:
如果選擇:
則會產生對應的 如果選擇:
則會產生對應的 如果選擇:
則會產生對應的字串陣列宣告。 完整操作流程實際使用時的流程就是:
不需要先將內容貼到 Visual Studio,再執行轉換。 Excel Paste 會直接讀取目前 Windows 剪貼簿中的表格文字並產生 C# 程式碼。 範例試算表內容:
使用:
產生:
如果儲存格中包含空白:
空白儲存格會被忽略:
如果內容包含雙引號或反斜線,Excel Paste 也會自動轉換成合法的 C# 字串內容。
隱私權Excel Paste 只會在使用者主動執行 Excel Paste 貼上命令時,讀取目前本機剪貼簿中的文字內容,並將轉換後的結果插入 Visual Studio 程式碼編輯器。 本延伸模組不會:
所有轉換作業皆於本機 Visual Studio 環境中完成。 EnglishExcel Paste is a Visual Studio extension that converts cells copied from Excel, Google Sheets, or other spreadsheet applications directly into C# string collection declarations. Features
Supported versions
Visual Studio 2019 and Visual Studio 2022/2026 use separate VSIX packages. Install the package that matches your Visual Studio version. Usage1. Copy cells from a spreadsheetSelect one or more cells in Excel, Google Sheets, or another spreadsheet application and copy them. For example:
Excel Paste uses tabs and line breaks to identify the copied cells and converts them into a one-dimensional collection. 2. Return to the Visual Studio code editorOpen the For example:
3. Right-click inside the code editorRight-click directly inside the Visual Studio code editor. The context menu will contain the Excel Paste commands. Choose the C# collection type you want to generate, for example:
After selecting a command, Excel Paste reads the current clipboard text, converts the copied spreadsheet cells, and inserts the generated C# code at the current cursor position. For example, selecting:
generates:
Selecting another command generates the corresponding collection type. Complete workflow
You do not need to paste the spreadsheet contents into Visual Studio before running Excel Paste. Excel Paste reads the current Windows clipboard directly and converts it into C# code. ExampleSpreadsheet content:
Choose:
Result:
Blank cells are automatically ignored. For example:
becomes:
Backslashes and double quotes are automatically escaped so the generated output remains valid C# code.
PrivacyExcel Paste reads local clipboard text only when the user explicitly runs an Excel Paste command and inserts the converted result into the Visual Studio editor. The extension does not:
All conversion is performed locally inside the Visual Studio environment. |