前言介紹
- 這款 WordPress 外掛「CSV Format」是 2015-07-27 上架。
- 目前有 10 個安裝啟用數。
- 上一次更新是 2015-08-14,距離現在已有 3551 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 3.6.1 以上版本才可以安裝。
- 尚未有人給過這款外掛評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
meglio |
外掛標籤
csv | excel | CSV API | comma-separated | comma separated values |
內容簡介
這個 WordPress 外掛可以從本地檔案、WordPress 媒體檔案、本地或遠端的資料庫或第三方 API 讀取 CSV 資料,並使用簡碼在 WordPress 的任何地方輸出,例如在文章、頁面、標題/頁腳、小工具或 Visual Composer 中。
您可以設定如何解析 CSV,包括指定分隔字元、封套字元和跳脫字元。
這是一個免費的附加元件,可以將 CSV 支援(逗號分隔值)添加到 Twig Anything WordPress 外掛中。
下面的教程演示了三個範例:
範例 1:產生多行文字,每行來自 CSV
範例 2:產生一個表格
範例 3:使用簡碼來在 WordPress 的任何地方輸出 CSV
範例 1:多行文字
讓我們使用一個 CSV 檔案,列出各個國家和它們對應的頂級網域名稱(TLD)。
比利時,布魯塞爾,EUR,歐元,BE,.be
貝里斯,Belmopan,BZD,美元,BZ,.bz
貝南,波多諾伏,XOF,法郎,BJ,.bj
不丹,廷布, BTN,紐扣陀, BT,.bt
在範例中,讓我們顯示以“D”開頭的所有國家的 TLD:
丹麥 - .dk
吉布地 - .dj
多米尼加 - .dm
多明尼加共和國 - .do
列是從 #0 開始編號的,所以我們需要第 #0(國家名稱)和第 #5(頂級網域名稱)欄。
在 CSV 輸入解析後,將結果行作為數據變量傳遞到您的 Twig 模板。你可以使用for語法迴圈控制流程:
{% for row in data if row.0|slice(0,1)|upper == 'D' %}
{{ row.0 }} - {{row.5}}
{% endfor %}
{% for row in data %}...{% endfor %} 是迴圈,每一行 CSV 檔案將渲染一次。
讓我們來看看這段代碼:if row.0|slice(0,1)|upper == 'D'
首先,row.0 是我們訪問第 #0 欄,即國家名稱。接下來,|slice(0,1) 是一個 Twig 過濾器,它取得國家名稱的第一個字元。下一個過濾器是 |upper,它只是將前一個過濾器返回的第一個字元轉換為大寫。最後,我們只允許以“D”字母開頭的國家: == 'D'。
在迴圈內部,我們使用 {{row.0}} 顯示國家名稱,{{row.5}} 顯示 TLD 名稱,以及一個基本的HTML標記:
用於插入斷行,... 來使 TLD 名稱顯示粗體。
範例 2:表格
使用相同的 CSV 檔案,我們現在要在 HTML 標記內輸出數據,生成表格。
如果您對 HTML 不是很熟悉,我建議您查看以下教程,您將可以在十分鐘內學會!
教程 1
教程 2
您也可以使用以下表格生成器,只需將它們生成的 HTML 複製並粘貼到您的模板中即可。這些生成器還允許應用一些基本樣式,例如邊框、顏色、邊距、填充等。
生成器 1
生成器 2
原文外掛簡介
Read CSV data from local files, WordPres media files, local or remote databases or 3rd party API, and output it anywhere in WordPress with using shortcodes, in posts/pages, headers/footers, widgets or in Visual Composer.
You can configure how CSV is parsed by specifying delimiter character, enclosure character and escape character.
This is a free add-on that adds CSV support (comma-separated values) to the
Twig Anything WordPress plugin.
Tutorials below demonstrate 3 examples:
Example 1: generate text, one line for each line from CSV
Example 2: generate a table
Example 3: use shortcodes to output CSV anywhere in WordPress
EXAMPLE 1: MULTILINE TEXT
Let us use a CSV file with a list of countries and their corresponding top-level domain names (TLD). Here is an extract from the file:
Belgium,Brussels,EUR,Euro,BE,.be
Belize,Belmopan,BZD,Dollar,BZ,.bz
Benin,Porto-Novo,XOF,Franc,BJ,.bj
Bhutan,Thimphu,BTN,Ngultrum,BT,.bt
In our example, let’s display TLDs for all countries that start with “D”:
Denmark - .dk
Djibouti - .dj
Dominica - .dm
Dominican Republic - .do
Columns are numbered starting from #0, so we will need the column #0 (country name) and #5 (top-level domain name).
After the CSV input has been parsed, the resulting lines are passed to your Twig Template as the data variable. You can then loop over it with using “for” syntax::
{% for row in data if row.0|slice(0,1)|upper == 'D' %}
{{ row.0 }} - {{row.5}}
{% endfor %}
{% for row in data %}...{% endfor %} is the loop. The code inside the loop will be rendered once for every line from the CSV file.
Let us take a closer look at this piece: if row.0|slice(0,1)|upper == 'D'
First of all, row.0 is how we access column #0, a country name in our case. Next, |slice(0,1) is a Twig filter that takes the first character of the country name. The next filter is |upper and it simply uppercases the first letter returned by the previous filter. Finally, we only allow for countries that start with the “D” letter: == 'D'.
Inside the loop, we output a country name with using {{row.0}} and a TLD name with using {{row.5}}. Plus a very basic HTML markup:
to insert a line break and ... to make TLD name appear bold.
EXAMPLE 2: TABLE
Using the same CSV file, let’s now output our data in a table with using HTML markup.
If you are not very familiar with HTML, I recommend going through the following tutorials – you’ll learn in 10 minutes, I guarantee!
Tutorial 1
Tutorial 2
You can also use the following table generators and just copy-paste the HTML they generate right into your template. The generators also allow to apply some basic styling, like borders, colors, margins, paddings etc.
Generator 1
Generator 2
So, we will use the following HTML tags:
to make a table
...to make a table header with column headings
...to make a table body with all the rows from CSV
to make a table row
to make a cell in the header’s row
to make a cell in a regular rows in the table’s body
Here is our template:
Country | TLD |
---|---|
{{ row.0 }} | {{ row.5 }} |
Notice how we use the {% for row in data %} syntax to loop over CSV lines,
and then output a table row
inside the loop, so that
a new row is made for every CSV line.
Actually, you can use just any HTML and stylize your table the way you need.
Just don’t forget to put {{row.0}}, {{row.1}} etc where you want
your csv values in the cells
.
EXAMPLE 3: SHORTCODES
While you prepare your template, you usually preview it many times by clicking
the “Preview Changes” button. Once you are happy with the preview, you will
want to embed it somewhere – in a post or a page, footer / header,
in a widget or as a Visual Composer block.
To embed your template, you will use a shortcode:
[twig-anything slug="my-template-slug"]
In WordPress, every Twig Template has its own slug, just like posts and pages.
It can be found under the template title.
Alternatively, you can use the template ID:
[twig-anything id="123"]
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「CSV Format」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
延伸相關外掛(你可能也想知道)
TablePress – Tables in WordPress made easy 》TablePress 是最受歡迎和評分最高的 WordPress 表格外掛程式。它允許您輕鬆地在您的網站上創建和管理美麗的表格。您可以使用區塊編輯器在文章、頁面或其他網...。
Import any XML, CSV or Excel File to WordPress 》WP All Import - 簡單且強大的 XML / CSV 匯入外掛程式, "這是一款功能豐富、表現優秀的外掛程式,難以一一列舉所有功能。但我可以告訴你,我能在不到 30 分...。
Import and export users and customers 》在您的免費測試網站中試試看:點擊此處 => https://demo.tastewp.com/import-users-from-csv-with-meta, 一個乾淨易用的用戶和客戶導入/導出外掛,適用於 ...。
wpDataTables – WordPress Data Table, Dynamic Tables & Table Charts Plugin 》wpDataTables 是一款流行的 WordPress 插件,可用於快速從 Excel、CSV、XML、JSON、PHP 和其他數據源創建表格和表格圖表。使用我們的 WP 表格插件,以簡潔、...。
WP Import Export Lite 》o.com/goto/wpimportexport" target="_blank">WordPress Import Export 插件 是一款易用、快速且進階的匯入和匯出網站數據的工具。, WordPress Import Export...。
Really Simple CSV Importer 》替代 CSV 導入外掛程式。簡單而強大,最適合於技術狂熱者。, , 類別支援, 標籤支援, 自訂欄位支援, Smart Custom Fields 支援, Custom Field Suite 支援, Adv...。
Import Export Suite for CSV and XML Datafeed 》內容遷移變得更加容易了, 您的內容很重要——信任 WP Ultimate CSV Importer, 現在,您可以使用我們的全功能導入導出捆綁工具快速方便地從 XML 和 CSV 文件中導...。
Import Users from CSV 》這個外掛允許您從上傳的 CSV 檔案中匯入使用者,會新增使用者的基本資訊、元資料欄位和使用者角色。, 您還可以選擇通知新使用者並在使用者登錄時顯示密碼提示...。
WP CSV Exporter 》這個外掛程式可以按照每篇文章類型將文章匯出為 CSV 格式。, 此外,它也支援文章的自訂欄位和自訂分類法。, 您還可以設定要下載的文章數量或日期範圍。, 如何...。
Product Export for WooCommerce to CSV, Excel, XML, and the Google Merchant Center 》使用 WooCommerce 產品匯出外掛程式 WP All Export Add-On,可以匯出產品資訊為 CSV、Excel 或 XML 檔案。WP All Export 提供了選擇匯出的產品欄位,按需要重...。
Get Use APIs – JSON Content Importer 》在你的 WordPress 網站上展示 JSON-Feed/API 的即時資料!, 從網址上抓取 JSON 資料並在 WordPress 頁面上轉換為 HTML。, JSON Content Importer-API-和 Web...。
Simple CSV/XLS Exporter 》本外掛可以讓您透過簡單的連結/按鈕,從後端或前端匯出文章為 CSV 或 XLS 檔案。, 請確保您使用 PHP 7.3 或更新版本,如果您看到任何錯誤,舊版本將不再受支...。
RS CSV Importer Media Add-On 》真正簡單的 CSV 匯入程式 附加元件。, CSV 中包含媒體(例如圖片、文件等)的 URL,下載媒體並將 URL 轉換為附件 ID。。
Import WP – Export and Import CSV and XML files to WordPress 》我們的 WordPress 優化匯入工具可輕鬆匯入及匯出 CSV 和 XML 檔案至 WordPress 文章、頁面、分類、標籤、自訂文章類型及自訂分類法。我們簡化了匯入附件、圖...。
User Import with meta 》通過 CSV 試算表導入帶有元數據詳細信息、自定義字段、WooCommerce 運輸詳細信息等用戶。, 重要提示: 此外掛是附加功能。因此,必須先安裝WP Ultimate CSV Im...。