কম্পিউটার

পাইথন - openpyxl মডিউল ব্যবহার করে একটি এক্সেল ফাইলে লেখা


Openpyxl হল এক্সেল (xlsx/xlsm/xltx/xltm এক্সটেনশন সহ) ফাইল পড়ার এবং লেখার জন্য একটি পাইথন লাইব্রেরি। Openpyxl মডিউল পাইথন প্রোগ্রামকে এক্সেল ফাইল পড়তে এবং পরিবর্তন করতে দেয়।

উদাহরণস্বরূপ, ব্যবহারকারীকে হাজার হাজার সারি দিয়ে যেতে হতে পারে এবং কিছু মানদণ্ডের উপর ভিত্তি করে ছোট পরিবর্তন করতে কয়েকটি মুষ্টিমেয় তথ্য বাছাই করতে হতে পারে। Openpyxl মডিউল ব্যবহার করে, এই কাজগুলো খুব দক্ষতার সাথে এবং সহজে করা যায়।

উদাহরণ

# import openpyxl module
import openpyxl  
#Call a Workbook() func of openpyxl to create a new blank Workbook object
wb = openpyxl.Workbook()  
# Get workbook active sheet from the active attribute
sheet = wb.active  
# Cell objects also have row, column and coordinate attributes that provide
# location information for the cell.
# The first row or column integer is 1, not 0. Cell object is created by
# using sheet object's cell() method.
c1 = sheet.cell(row = 1, column = 1)
# writing values to cells
c1.value = "Vishesh"  
c2 = sheet.cell(row= 1 , column = 2)
c2.value = "Ved"  
#Once have a Worksheet object,one can access a cell object by its name also
# A2 means column = 1 & row = 2.
c3 = sheet['A2']
c3.value = "Python"
# B2 means column = 2 & row = 2.
c4 = sheet['B2']
c4.value = "Programming"  
#Anytime you modify the Workbook object or its sheets and cells, the #spreadsheet file will not be saved until you call the #save()workbook method.
wb.save("C:\\Users\\Vishesh\\Desktop\\demo.xlsx")

  1. পাইথনে xlsxwriter মডিউল ব্যবহার করে এক্সেল ফাইল তৈরি করুন এবং লিখুন

  2. পাইথনে openpyxl ব্যবহার করে এক্সেল ফাইলে গাণিতিক ক্রিয়াকলাপ

  3. Python ব্যবহার করে ওয়েবসাইট ব্লকার

  4. পাইথন openpyxl মডিউল ব্যবহার করে একটি এক্সেল ফাইল পড়ুন এবং লিখুন