ในบทความนี้ ผมจะพูดถึงวิธีการแปลงไฟล์ CSV เป็นไฟล์ excel ที่มีหลายคอลัมน์ (.xlsx รูปแบบ). เนื่องจากไฟล์ CSV นั้นใช้งานง่ายและเปิดได้ด้วยแอปพลิเคชันทั่วไป เราจึงมักได้รับข้อมูลใน .csv รูปแบบ. ต่อมา เนื่องจากการคำนวณเพิ่มเติมหรือการแสดงข้อมูลที่ดีขึ้น เราจึงต้องแปลงไฟล์ CSV เป็นไฟล์ excel มาดูบทความเพื่อเรียนรู้การแปลง CSV เป็น excel กัน
คุณสามารถดาวน์โหลดแบบฝึกหัดที่เราใช้ในการเตรียมบทความนี้ได้
ไฟล์ CSV คืออะไร
CSV ย่อมาจากค่าที่คั่นด้วยจุลภาค นี่คือรูปแบบไฟล์ข้อความธรรมดาที่คั่นข้อมูลด้วยเครื่องหมายจุลภาค คุณสามารถเปิดไฟล์ CSV โดยใช้โปรแกรมแก้ไขข้อความอย่างง่าย เช่น Notepad . นอกจากนี้ เราสามารถเปิดไฟล์ CSV ผ่านแอปพลิเคชันสเปรดชีต เช่น Excel หรือ Google ชีต .
ไฟล์ Excel คืออะไร
ไฟล์ Excel ที่สร้างจาก Microsoft Excel ส่วนใหญ่มี .xlsx นามสกุลไฟล์. ไฟล์เหล่านี้สามารถเปิดได้ผ่านซอฟต์แวร์สเปรดชีต เช่น Google ชีต , เปิดสำนักงาน , หรือ Microsoft Excel . ต่างจากไฟล์ CSV คุณสามารถทำการคำนวณต่างๆ ในไฟล์ excel ได้ นอกจากนั้น ในไฟล์ excel คุณสามารถใช้เทคนิคการแสดงข้อมูลที่หลากหลายเพื่อให้เข้าใจรูปแบบของข้อมูลได้ละเอียดยิ่งขึ้น
5 วิธีในการแปลง CSV เป็น Excel ด้วยคอลัมน์
1. ใช้ตัวเลือก 'บันทึกเป็น' เพื่อเปลี่ยนไฟล์ CSV เป็น Excel
สมมติว่าเราเปิดไฟล์ CSV ด้านล่างด้วย Notepad . ข้อมูลในไฟล์ด้านล่างถูกแยกออกเป็นหลายคอลัมน์ อย่างไรก็ตาม เราจะเห็นเฉพาะค่าที่คั่นด้วยเครื่องหมายจุลภาคใน Notepad .
ตอนนี้ ฉันจะแปลง CSV ไฟล์ลงในไฟล์ excel ทำตามขั้นตอนด้านล่างเพื่อทำงาน
ขั้นตอน:
- ขั้นแรก อย่าเปิดไฟล์ CSV ให้คลิกขวาที่ไฟล์แล้วไปที่เปิดด้วย> Excel .
- ด้วยเหตุนี้ ไฟล์ CSV จึงเปิดขึ้นใน Microsoft Excel . ถัดไป จาก Excel Ribbon ให้คลิกที่ ไฟล์ แท็บ
- ไปที่ ไฟล์ > บันทึกเป็น> เรียกดู .
- จากนั้น บันทึกเป็น กล่องโต้ตอบปรากฏขึ้น ที่นี่ ไปที่ตำแหน่งที่คุณต้องการบันทึกไฟล์
- หลังจากนั้น ให้ ชื่อไฟล์ แล้วเลือกบันทึกเป็นประเภท : สมุดงาน Excel (*.xlsx) . กด บันทึก เมื่อคุณเสร็จสิ้นกระบวนการ
- สุดท้าย คุณจะเห็นไฟล์ CSV ด้านบนถูกแปลงเป็นไฟล์ Excel คุณสามารถดูข้อมูลถูกแยกออกเป็นคอลัมน์ ต่อมา จัดรูปแบบข้อมูลตามความต้องการของคุณ
2. แทรกตัวเลือก 'ข้อความเป็นคอลัมน์' เพื่อแปลง CSV เป็น Excel ด้วยคอลัมน์
คราวนี้ฉันจะแปลงข้อมูลไฟล์ CSV เป็นหลายคอลัมน์ใน excel ที่นี่ ฉันจะใช้ฟังก์ชัน text to column ใน excel เพื่อแปลงข้อมูลคอลัมน์เดียวเป็นหลายคอลัมน์
ขั้นตอน:
- เริ่มแรก เปิดไฟล์ CSV ด้วย excel
- ถัดไป เลือกคอลัมน์ (คอลัมน์ A ) ที่มีค่าคั่นด้วยเครื่องหมายจุลภาค
- ตอนนี้ ไปที่ ข้อมูล > ข้อความเป็นคอลัมน์ .
- ด้วยเหตุนี้ ตัวช่วยสร้างการแปลง ข้อความเป็นคอลัมน์ ปรากฏขึ้น คลิกที่ คั่น แล้วกด ถัดไป .
- ทำเครื่องหมายที่จุลภาค เมื่อวิซาร์ดตัวต่อไปปรากฏขึ้น กด ถัดไป อีกครั้ง
- จากนั้นเลือก ปลายทาง ตำแหน่ง แล้วกด เสร็จสิ้น .
- ด้วยเหตุนี้ เราจะได้ผลลัพธ์ด้านล่างใน excel
- แม้ว่าข้อมูลของเราจะถูกแยกออกเป็นคอลัมน์ในขณะนี้ แต่ยังคงเป็นไฟล์ CSV ในการแปลงไฟล์เป็นไฟล์ excel เราต้องบันทึกไฟล์เป็น .xlsx รูปแบบ. โดยไปที่ไฟล์ > บันทึกเป็น > เรียกดู (ดู วิธีที่ 1) .
- เมื่อ บันทึกเป็น dialog appears, type the File Name and choose the .xlsx file format, and press Save (see Method 1 )
อ่านเพิ่มเติม: How to Convert CSV to XLSX Command Line (with Easy Steps)
3. Convert CSV to Excel Files Using ‘From Text/CSV’ Feature
I will import a CSV file into excel using the ‘From Text/CSV ’ feature in this method. Later, I will save the data as an excel file with columns. Follow the below steps to do the task.
ขั้นตอน:
- Firstly, open Excel and go to Data> From Text/CSV icon .
- Next, the Import Data dialog will appear. From there, select the CSV file that you want to import and press Import .
- Consequently, the CSV file is imported into excel as below. Now, click on Load .
- As a result, we can see the data from the CSV file is loaded as in the below table.
- Click on the table, and thus the Table Design tab appears.
- Go to Table Design> Convert to Range .
- Excel will prompt the below warning, press OK .
- Upon clicking OK , we will get the below range. If you want you can clear the cell formatting by going to Home> Editing > Clear > Clear Formats .
- Later you can format the dataset as you like. Go to the File tab to bring the Save ตัวเลือก
- Afterward, click on Save .
- When the Save As dialog come up, give a name to your file and press Save . So, finally, now you have the CSV file converted into an excel file (with columns).
⏩ Note:
You can get the ‘From Text/CSV ‘ by following the path Data > Get Data> From File > From Text/CSV too.
อ่านเพิ่มเติม: Excel VBA to Import CSV File without Opening (3 Suitable Examples)
การอ่านที่คล้ายกัน
- Excel VBA to Read CSV File into Array (4 Ideal Examples)
- How to Import CSV into Existing Sheet in Excel (5 Methods)
- Excel VBA:Read a Text File Line by Line (6 Related Examples)
- How to Import Text File to Excel Using VBA (3 Easy Ways)
- Excel VBA:Import Comma Delimited Text File (2 Cases)
4. CSV to Excel File Conversion with ‘Legacy Wizard’ Feature
Now I will import a CSV file using the Legacy Wizard from the Get Data ตัวเลือก. Before importing the CSV file, I will show you how you can add the legacy wizard to excel.
ขั้นตอน:
- After opening Excel , first, go to the File แท็บ
- Then go to Options .
- Consequently, the Excel Options dialog shows up. From the dialog, go to Data ตัวเลือก
- Now put a checkmark on From Text (Legacy) แล้วกด ตกลง .
- As a result, the From Text (Legacy) feature is added to excel. To apply the feature go to Data> Get Data > Legacy Wizard> From Text (Legacy) .
- Consequently, the Import Text File dialog appears, choose the CSV file you want to get in excel, and press Import .
- After that, the Text Import Wizard shows up. Here, click on the Delimited , put a checkmark on My data has headers , and press Next .
- Put a checkmark on Comma and again press Next .
- Press Finish after that.
- As a consequence the Import Data dialog shows up, choose the data destination location, and press OK .
- Finally, we can see that CSV data is imported into excel, separated by columns.
- Likewise described in Method 3 , we will save the data. To do that, go to the File แท็บ
- Then go to Save , type a file name and click Save (see Method 3 )
อ่านเพิ่มเติม: How to Import Text File to Excel Automatically (2 Suitable Ways)
5. Excel VBA to Transform CSV to Excel with Columns
You can use Excel VBA to convert CSV files into excel files with multiple columns. Suppose we have a CSV file in a specified location stated below.
Now I will convert the CSV file into Excel with columns. Let’s follow the below process to do the task.
ขั้นตอน:
- Open Excel , and go to Developer > Visual Basic to bring the VBA หน้าต่าง
- When the VBA window appears, go to Insert> Module .
- Then, type the below code in the newly opened Module . Save the file and run the code using the F5 ที่สำคัญ
Sub Convert_CSV_to_EXCEL()
Dim w As Workbook
Set w = Workbooks.Open("C:\Users\User\OneDrive\Desktop\ExcelDemy\How to Convert CSV to Excel with Columns\CSV FIle.csv")
w.SaveAs Filename:="C:\Users\User\OneDrive\Desktop\ExcelDemy\How to Convert CSV to Excel with Columns\CSV FIle.xlsx", _
FileFormat:=xlWorkbookDefault, _
ReadOnlyRecommended:=False, CreateBackup:=False
End Sub
- Upon running the code, you will see the below excel file with multiple columns is created.
- Now if you go to the CSV file location, you will see the newly created excel (with .xlsx extension) file too.
บทสรุป
In the above article, I have tried to discuss several methods to convert CSV files into excel files elaborately. หวังว่าวิธีการและคำอธิบายเหล่านี้จะเพียงพอที่จะแก้ปัญหาของคุณได้ โปรดแจ้งให้เราทราบหากคุณมีข้อสงสัยใดๆ
บทความที่เกี่ยวข้อง
- How to Convert CSV to XLSX (4 Quick Methods)
- Excel VBA to Read CSV File Line by Line (3 Ideal Examples)
- How to Open Notepad or Text File in Excel with Columns (3 Easy Methods)
- Excel VBA to Convert CSV File to XLSX (2 Easy Examples)
- How to Open CSV File in Excel with Columns Automatically (3 Methods)