ওয়ার্ড প্রসেসিং ডকুমেন্ট তৈরি করার জন্য .NET লাইব্রেরি

Word ফাইলগুলি পড়ুন, লিখুন, ম্যানিপুলেট করুন এবং রূপান্তর করুন, ওপেন সোর্স .NET API-এর মাধ্যমে DOCX-এ টেবিল তৈরি করুন।

Open XML SDK হল একটি ওপেন সোর্স API, যা Microsoft-এর দ্বারা তৈরি করা হয়েছে এবং সহ ওয়ার্ড প্রসেসিং ডকুমেন্টগুলিকে ম্যানিপুলেট করার জন্য Microsoft ওপেন সোর্স কোড অফ কন্ডাক্টের অধীনে বিতরণ করা হয়েছে। DOCXDOTXDOCMDOTM ফাইল ফরম্যাট

API ব্যবহার করে, আপনি টেক্সট, হেডার, ফুটার, এন্ডনোট, পাদটীকা, শৈলী, থিম এবং আরও অনেক কিছু যোগ করতে পারেন। এটি আপনাকে উচ্চ-পারফরম্যান্স ওয়ার্ড ডকুমেন্ট তৈরি করতে এবং সেগুলি থেকে ডেটা বের করতে দেয়। API .NET 3.5, .NET 4.0, .NET 4.6, এবং .NET স্ট্যান্ডার্ড 1.3 সহ বিভিন্ন .NET প্ল্যাটফর্ম সমর্থন করে৷

Previous Next

ওপেন XML SDK দিয়ে শুরু করা

প্রথমত, আপনার .NET ফ্রেমওয়ার্ক 3.5 বা তার উপরে থাকতে হবে। এর পরে, অনুগ্রহ করে GitHub থেকে সংগ্রহস্থলটি ম্যানুয়ালি ডাউনলোড করুন বা এটি NuGet

ইনস্টলেশন  NuGet থেকে XML SDK খুলুন

 Install-Package DocumentFormat.OpenXml

C# ব্যবহার করে DOCX ফাইল ম্যানিপুলেট করুন

ওপেন XML SDK .NET প্রোগ্রামারদের তাদের নিজস্ব .NET অ্যাপ্লিকেশন থেকে ওয়ার্ড প্রসেসিং তৈরি করার পাশাপাশি পরিবর্তন করতে দেয়। একটি বিদ্যমান ফাইল পরিবর্তন করার জন্য, আপনি একটি বিদ্যমান ফাইল খুলতে পারেন এবং পাঠ্য, অনুচ্ছেদ, টেবিল এবং আরও অনেক কিছুর মতো পরিবর্তনগুলি যুক্ত করতে পারেন।

DOCX - C# এ অনুচ্ছেদ যোগ করুন

// Open an existing word processing document
using (WordprocessingDocument wordprocessingDocument = WordprocessingDocument.Open("fileformat.docx", true))
{
  Body body = wordprocessingDocument.MainDocumentPart.Document.Body;
  // Add paragraph
  Paragraph para = body.AppendChild(new Paragraph());
  Run run = para.AppendChild(new Run());
  run.AppendChild(new Text("File Format Developer Guide"));
}

C# ব্যবহার করে DOCX এ একটি টেবিল তৈরি করুন

API ডেভেলপারদের ওয়ার্ড প্রসেসিং নথিতে একটি টেবিল যোগ করার অনুমতি দেয়। আপনি একটি টেবিল যোগ করতে পারেন, টেবিল বৈশিষ্ট্য সেট, টেবিল গ্রিড সেট, এবং কলাম গ্রিড বৈশিষ্ট্য. উপরন্তু, আপনি যথাক্রমে TableCell এবং TableRow ক্লাস ব্যবহার করে টেবিল সেল এবং সারি পরিচালনা করতে পারেন।

DOCX - C# এ টেবিল তৈরি করুন

// Open an existing word processing document
using (WordprocessingDocument wordprocessingDocument = WordprocessingDocument.Open("fileformat.docx", true))
{
  Body body = wordprocessingDocument.MainDocumentPart.Document.Body;
  // Create a table.
  Table table = new Table();
  // Set the style and width for the table.
  TableProperties tableProperties = new TableProperties();
  TableStyle tableStyle = new TableStyle() { Val = "TableGrid" };
  // Make the table width 100% of the page width.
  TableWidth tableWidth = new TableWidth() { Width = "5000", Type = TableWidthUnitValues.Pct };
  // Apply
  tableProperties.Append(tableStyle, tableWidth);
  table.AppendChild(tableProperties);
  // Add columns
  TableGrid tableGrid = new TableGrid(new GridColumn(), new GridColumn(), new GridColumn());
  table.AppendChild(tableGrid);
  // Create 1 row to the table.
  TableRow tableRow = new TableRow();
  // Add a cell to each column in the row.
  TableCell tableCell = new TableCell(new Paragraph(new Run(new Text("Column 1"))));
  TableCell tableCell1 = new TableCell(new Paragraph(new Run(new Text("Column 2"))));
  //Append data
  tableRow.Append(tableCell, tableCell1);
  // Add row to the table.
  table.AppendChild(tableRow);
  // Add the table to the document
  body.AppendChild(table);
}

ওয়ার্ড প্রসেসিং ডকুমেন্টে হেডার ও ফুটার

নথির সঠিক সংগঠন খুবই গুরুত্বপূর্ণ এবং প্রতিটি প্রতিষ্ঠানের প্রয়োজন। শিরোনাম এবং পাদচরণ নথিগুলির মূল অংশ যা কিছু অতিরিক্ত তথ্য যেমন প্রাসঙ্গিক তারিখ, বিষয়, লেখকের নাম, ছবি, পৃষ্ঠা নম্বর ইত্যাদি স্থাপন করে শব্দ প্রক্রিয়াকরণ নথিগুলিকে সঠিকভাবে সংগঠিত করতে সাহায্য করতে পারে। এটি একাধিক শিরোনাম সংযোজন সমর্থন করে।

ওয়ার্ড ডকুমেন্টে হেডার ম্যানেজ করুন

 
public static void ApplyHeader(WordprocessingDocument doc)
{
  // Get the main document part.
  MainDocumentPart mainDocPart = doc.MainDocumentPart;
  HeaderPart headerPart1 = mainDocPart.AddNewPart("r97");
  Header header1 = new Header();
  Paragraph paragraph1 = new Paragraph(){ };
  Run run1 = new Run();
  Text text1 = new Text();
  text1.Text = "Header stuff";
  run1.Append(text1);
  paragraph1.Append(run1);
  header1.Append(paragraph1);
  headerPart1.Header = header1;
  SectionProperties sectionProperties1 = mainDocPart.Document.Body.Descendants().FirstOrDefault();
  if (sectionProperties1 == null)
  {
  sectionProperties1 = new SectionProperties() { };
  mainDocPart.Document.Body.Append(sectionProperties1);
  }
  HeaderReference headerReference1 = new HeaderReference() { Type = HeaderFooterValues.Default, Id = "r97" };
  sectionProperties1.InsertAt(headerReference1,0);
}

ওয়ার্ড ডকুমেন্টে পাদচরণ পরিচালনা করুন

 
public static void ApplyFooter(WordprocessingDocument doc)
{
  // Get the main document part.
  MainDocumentPart mainDocPart = doc.MainDocumentPart;
  FooterPart footerPart1 = mainDocPart.AddNewPart("r98");
  Footer footer1 = new Footer();
  Paragraph paragraph1 = new Paragraph() { };
  Run run1 = new Run();
  Text text1 = new Text();
  text1.Text = "Footer stuff";
  run1.Append(text1);
  paragraph1.Append(run1);
  footer1.Append(paragraph1);
  footerPart1.Footer = footer1;
  SectionProperties sectionProperties1 = mainDocPart.Document.Body.Descendants().FirstOrDefault();
  if (sectionProperties1 == null)
  {
    sectionProperties1 = new SectionProperties() { };
    mainDocPart.Document.Body.Append(sectionProperties1);
  }
  FooterReference footerReference1 = new FooterReference() { Type = DocumentFormat.OpenXml.Wordprocessing.HeaderFooterValues.Default, Id = "r98" };
  sectionProperties1.InsertAt(footerReference1, 0);
}
 বাংলা