Skip to content
| Marketplace
Sign in
Visual Studio>Tools>Excel-Paste for Visual Studio 2019
Excel-Paste for Visual Studio 2019

Excel-Paste for Visual Studio 2019

calaw1110

| (0) | Free
Paste spreadsheet cells as C# collection declarations (IReadOnlyList, List, HashSet, string[]). ????????? C# ?????
Download

Excel Paste

繁體中文 | English

繁體中文

Excel Paste 是 Visual Studio 延伸模組,可將從 Excel、Google 試算表或其他表格工具複製的儲存格內容,直接轉換成 C# 字串集合宣告並插入程式碼編輯器。

功能

  • 將 Tab、換行分隔的儲存格轉成一維字串集合
  • 自動忽略空白儲存格
  • 自動移除每個儲存格內容前後的空白
  • 自動跳脫反斜線 \ 與雙引號 "
  • 支援 IReadOnlyList<string>、List<string>、HashSet<string> 與 string[]
  • 可直接從 Visual Studio 程式碼編輯器的右鍵選單選擇輸出型別

支援版本

安裝套件 Visual Studio
Excel Paste for VS 2019 Visual Studio 2019 16.x
Excel Paste for VS 2022/2026 Visual Studio 2022 17.x、Visual Studio 2026 18.x

Visual Studio 2019 與 Visual Studio 2022/2026 使用不同的 VSIX 套件,請安裝符合目前 Visual Studio 版本的套件。

使用方式

1. 從試算表複製資料

在 Excel、Google 試算表或其他支援表格複製的工具中,選取一個或多個儲存格後執行複製。

例如複製以下內容:

Taipei	Taichung
Tainan	Kaohsiung

Excel Paste 會依照 Tab 與換行,自動將所有儲存格整理成一維集合。

2. 回到 Visual Studio 程式碼編輯器

開啟要插入程式碼的 .cs 檔案,並將游標移到希望插入集合宣告的位置。

例如:

public void Test()
{
    // 將游標放在這裡
}

3. 在程式碼編輯器中按滑鼠右鍵

請在 Visual Studio 的「程式碼編輯區域」內按滑鼠右鍵。

右鍵選單中會出現 Excel Paste 提供的貼上功能。

從選單中選擇需要的 C# 集合型別,例如:

  • Paste as IReadOnlyList<string>
  • Paste as List<string>
  • Paste as HashSet<string>
  • Paste as string[]

選擇後,Excel Paste 會讀取目前剪貼簿中的試算表內容,立即轉換並插入到目前游標位置。

例如選擇:

Paste as IReadOnlyList<string>

會產生:

IReadOnlyList<string> values = ["Taipei", "Taichung", "Tainan", "Kaohsiung"];

如果選擇:

Paste as List<string>

則會產生對應的 List<string> 宣告。

如果選擇:

Paste as HashSet<string>

則會產生對應的 HashSet<string> 宣告。

如果選擇:

Paste as string[]

則會產生對應的字串陣列宣告。

完整操作流程

實際使用時的流程就是:

Excel / Google 試算表
        ↓
選取儲存格
        ↓
Ctrl + C
        ↓
回到 Visual Studio
        ↓
將游標移到要插入程式碼的位置
        ↓
在程式碼編輯器內按滑鼠右鍵
        ↓
選擇 Excel Paste 的輸出型別
        ↓
自動產生 C# 集合宣告

不需要先將內容貼到 Visual Studio,再執行轉換。

Excel Paste 會直接讀取目前 Windows 剪貼簿中的表格文字並產生 C# 程式碼。

範例

試算表內容:

能力名稱	孩子年齡	匹配報告月份	報告文字

使用:

Paste as IReadOnlyList<string>

產生:

IReadOnlyList<string> values = ["能力名稱", "孩子年齡", "匹配報告月份", "報告文字"];

如果儲存格中包含空白:

Taipei		Taichung

空白儲存格會被忽略:

IReadOnlyList<string> values = ["Taipei", "Taichung"];

如果內容包含雙引號或反斜線,Excel Paste 也會自動轉換成合法的 C# 字串內容。

產生的集合運算式語法需要 C# 12 或更新版本。

隱私權

Excel Paste 只會在使用者主動執行 Excel Paste 貼上命令時,讀取目前本機剪貼簿中的文字內容,並將轉換後的結果插入 Visual Studio 程式碼編輯器。

本延伸模組不會:

  • 收集或儲存剪貼簿內容
  • 收集或儲存原始碼
  • 收集個人資料
  • 收集遙測資料
  • 收集使用統計資料
  • 將任何內容傳送至外部伺服器
  • 連線至任何外部服務

所有轉換作業皆於本機 Visual Studio 環境中完成。


English

Excel 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

  • Converts tab- and line-separated cells into a one-dimensional string collection
  • Automatically ignores blank cells
  • Trims surrounding whitespace from each cell
  • Escapes backslashes \ and double quotes "
  • Supports IReadOnlyList<string>, List<string>, HashSet<string>, and string[]
  • Lets you select the output type directly from the Visual Studio code editor context menu

Supported versions

Package Visual Studio
Excel Paste for VS 2019 Visual Studio 2019 16.x
Excel Paste for VS 2022/2026 Visual Studio 2022 17.x and Visual Studio 2026 18.x

Visual Studio 2019 and Visual Studio 2022/2026 use separate VSIX packages. Install the package that matches your Visual Studio version.

Usage

1. Copy cells from a spreadsheet

Select one or more cells in Excel, Google Sheets, or another spreadsheet application and copy them.

For example:

Taipei	Taichung
Tainan	Kaohsiung

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 editor

Open the .cs file where you want to insert the generated code and place the text cursor at the desired location.

For example:

public void Test()
{
    // Place the cursor here
}

3. Right-click inside the code editor

Right-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:

  • Paste as IReadOnlyList<string>
  • Paste as List<string>
  • Paste as HashSet<string>
  • Paste as string[]

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:

Paste as IReadOnlyList<string>

generates:

IReadOnlyList<string> values = ["Taipei", "Taichung", "Tainan", "Kaohsiung"];

Selecting another command generates the corresponding collection type.

Complete workflow

Excel / Google Sheets
        ↓
Select cells
        ↓
Ctrl + C
        ↓
Return to Visual Studio
        ↓
Place the cursor where the code should be inserted
        ↓
Right-click inside the code editor
        ↓
Choose an Excel Paste output type
        ↓
C# collection declaration is inserted automatically

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.

Example

Spreadsheet content:

能力名稱	孩子年齡	匹配報告月份	報告文字

Choose:

Paste as IReadOnlyList<string>

Result:

IReadOnlyList<string> values = ["能力名稱", "孩子年齡", "匹配報告月份", "報告文字"];

Blank cells are automatically ignored.

For example:

Taipei		Taichung

becomes:

IReadOnlyList<string> values = ["Taipei", "Taichung"];

Backslashes and double quotes are automatically escaped so the generated output remains valid C# code.

The generated collection-expression syntax requires C# 12 or later.

Privacy

Excel 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:

  • Collect or store clipboard content
  • Collect or store source code
  • Collect personal data
  • Collect telemetry
  • Collect usage statistics
  • Transmit content to external servers
  • Connect to external services

All conversion is performed locally inside the Visual Studio environment.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft