पायथन का उपयोग करके PowerPoint में तालिका कैसे बनाएँ

यह सरल लेख पायथन का उपयोग करके PowerPoint में टेबल कैसे बनाएं पर मार्गदर्शन करता है। यह पर्यावरण को स्थापित करने के लिए सभी सूचनाओं को शामिल करता है, एक तालिका के अंदर डेटा डालने और भरने के लिए एक चरण-दर-चरण प्रक्रिया, और एक कार्यशील नमूना कोड जो दिखाता है कि Python का उपयोग करके स्लाइड में तालिका कैसे सम्मिलित करें। इसमें यह भी शामिल है कि तालिका सेल के अंदर पाठ को कैसे प्रारूपित किया जाए और प्रस्तुति को डिस्क पर PPT या PPTX प्रारूप में सहेजा जाए।

पायथन का उपयोग करके PowerPoint में तालिका बनाने के चरण

  1. तालिका जोड़ने के लिए अपने ऐप्लिकेशन में .NET के माध्यम से पायथन के लिए Aspose.Slides का उपयोग करने के लिए पर्यावरण कॉन्फ़िगर करें
  2. Presentation वर्ग का उपयोग करके एक नई रिक्त प्रस्तुति तैयार करें और इसकी पहली डिफ़ॉल्ट स्लाइड तक पहुंचें
  3. add_table() विधि का उपयोग करके परिभाषित कॉलम चौड़ाई और पंक्तियों की ऊंचाई वाली स्लाइड में तालिका डालें
  4. नई जोड़ी गई तालिका के अंदर प्रत्येक पंक्ति और उसके संबंधित सेल के माध्यम से आगे बढ़ें
  5. प्रत्येक सेल के अंदर इसके फॉन्ट-संबंधित गुणों के साथ नमूना पाठ सेट करें
  6. डिस्क पर पीपीटीएक्स प्रारूप में तालिका के साथ प्रस्तुति को सहेजें

उपरोक्त चरण समझाते हैं पायथन का उपयोग करके PowerPoint में टेबल कैसे बनाएं जिससे पहले चरण में, हम एक डिफ़ॉल्ट प्रस्तुति बनाएंगे और इसकी पहली स्लाइड तक पहुंचेंगे। बाद के चरणों में, हम कॉलम की चौड़ाई और पंक्तियों की ऊँचाई के साथ तालिका के लिए स्थिति निर्देशांक प्रदान करके एक तालिका जोड़ेंगे। अंतिम चरणों में, हम डिस्क पर परिणामी प्रस्तुति को सहेजने से पहले संबंधित स्वरूपण के साथ पाठ सेट करने के लिए तालिका के अंदर प्रत्येक सेल के माध्यम से पुनरावृति करेंगे।

पायथन का उपयोग करके PowerPoint में तालिका जोड़ने के लिए कोड

import aspose.pydrawing as draw
import aspose.slides as slides
# Path to the license file directory
filepath = "Y://Documents//KnowledgeBase//TestData//"
# Load the license in your application for creating the table
slidesTableLicense = slides.License()
slidesTableLicense.set_license(filepath + "Conholdate.Total.Product.Family.lic")
# Instantiate the Presentation object to add the table
with slides.Presentation() as presentationTable:
# Access the first default slide
slide = presentationTable.slides[0]
# Define the columns widths and rows heights
dblColsWidth = [50, 50, 50]
dblRowsHeight = [50, 30, 30, 30, 30]
# Insert the table shape to slide
table = slide.shapes.add_table(100, 50, dblColsWidth, dblRowsHeight)
# Set the border format for each cell
for rowIndex in range(len(table.rows)):
for cellIndex in range(len(table.rows[rowIndex])):
table.rows[rowIndex][cellIndex].cell_format.border_top.fill_format.fill_type = slides.FillType.SOLID
table.rows[rowIndex][cellIndex].cell_format.border_top.fill_format.solid_fill_color.color = draw.Color.red
table.rows[rowIndex][cellIndex].cell_format.border_top.width = 5
table.rows[rowIndex][cellIndex].cell_format.border_bottom.fill_format.fill_type = slides.FillType.SOLID
table.rows[rowIndex][cellIndex].cell_format.border_bottom.fill_format.solid_fill_color.color= draw.Color.red
table.rows[rowIndex][cellIndex].cell_format.border_bottom.width =5
table.rows[rowIndex][cellIndex].cell_format.border_left.fill_format.fill_type = slides.FillType.SOLID
table.rows[rowIndex][cellIndex].cell_format.border_left.fill_format.solid_fill_color.color =draw.Color.red
table.rows[rowIndex][cellIndex].cell_format.border_left.width = 5
table.rows[rowIndex][cellIndex].cell_format.border_right.fill_format.fill_type = slides.FillType.SOLID
table.rows[rowIndex][cellIndex].cell_format.border_right.fill_format.solid_fill_col or.color = draw.Color.red
table.rows[rowIndex][cellIndex].cell_format.border_right.width = 5
# Merge the cells 1 and 2 of row 1
table.merge_cells(table.rows[0][0], table.rows[1][1], False)
# Add the text inside the merged cell
table.rows[0][0].text_frame.text = "Merged Table Cells"
presentationTable.save(filepath + "NewPresentationWithTable.pptx", slides.export.SaveFormat.PPTX)
print("Done")

इस उदाहरण में पायथन का उपयोग करके PowerPoint में तालिकाएँ कैसे बनाएँ पर जोर दिया गया है, जहाँ पंक्तियों और स्तंभों के संग्रह वाली तालिका सम्मिलित करने के लिए तालिका वर्ग उदाहरण का उपयोग किया जाता है। TextFrame क्लास ऑब्जेक्ट पैराग्राफ़ टेक्स्ट के लिए टेक्स्ट, फ़ॉन्ट ऊंचाई और बुलेट प्रकार सेट करता है। आप अन्य संबंधित गुणों का भी उपयोग कर सकते हैं जैसे हाइलाइट टेक्स्ट, सेट भरण प्रारूप, फ़ील्ड जोड़ें या निकालें, और हाइलाइट रंग को कुछ नामों के लिए सेट करें।

इस विषय में बताया गया है कि पायथन का उपयोग करते हुए आप प्रेजेंटेशन में टेबल कैसे इन्सर्ट करेंगे। यदि आप प्रस्तुति को सुरक्षित करने के लिए वॉटरमार्क छवि जोड़ने के बारे में जानने में रुचि रखते हैं, तो पायथन का उपयोग करके PPTX में इमेज वॉटरमार्क कैसे जोड़ें पर लेख देखें।

 हिन्दी