C++ kullanarak DOCX'te Tablo Nasıl Oluşturulur

Bu konuda, C++ kullanarak DOCX içinde nasıl tablo oluşturulacağını göreceğiz. Tablolar genellikle kelime belgelerinde kullanılır ve C++ kullanarak DOCX’e tablo ekleyebilirsiniz. Basit API çağrılarını kullanarak Word tablosunu C++‘a ekleyebilirsiniz.

C++ Kullanarak DOCX’te Tablo Ekleme Adımları

  1. NuGet’ten Aspose.Words.Cpp uygulamasının en son sürümünü yükleyin
  2. Aspose::Words ad alanına başvuruyu dahil et
  3. Tablo eklemek üzere DOCX’i yüklemek üzere Document Class nesnesi oluşturun
  4. DOCX içindeki içeriği yönetmek için DocumentBuilder Class örneğini oluşturun
  5. Hücrenin içine satırlar, hücreler ve görüntü eklemek için DocumentBuilder’ı kullanın
  6. Save yöntemini kullanarak DOCX’i Table ile C++‘da kaydedin

Aşağıdaki örnekte, Microsoft Word’e bağımlı olmadan C++ kullanarak Word tablosu oluşturabilirsiniz. Tablo hücrelerinin içindeki içeriği biçimlendirebilirsiniz ve biz de hücre içine nasıl resim ekleneceğini gösterdik.

C++ kullanarak DOCX’te Tablo Ekleme Kodu

#pragma once
#include <cstdint>
#include <iostream>
#include <Aspose.Words.Cpp/Document.h>
#include <Aspose.Words.Cpp/DocumentBase.h>
#include <Aspose.Words.Cpp/DocumentBuilder.h>
#include <Aspose.Words.Cpp/Drawing/Shape.h>
#include <Aspose.Words.Cpp/HeaderFooterType.h>
#include <Aspose.Words.Cpp/Saving/SaveOutputParameters.h>
#include <system/array.h>
#include <system/exceptions.h>
#include <Aspose.Words.Cpp/License.h>
#include <system/io/path.h>
using System::ArrayPtr;
using System::MakeArray;
using System::MakeObject;
using System::SharedPtr;
using System::String;
using namespace Aspose::Words;
class CreateTableInWordDocumentUsingCpp
{
public:
void AddTableinWordDocument()
{
// Set License file name
System::String LicenseFile = u"Aspose.Total.NET.lic";
// Setting the Aspose.Words before creating Word document
SharedPtr<License> wordsLicenseForTable = System::MakeObject<License>();
// Setting product license
wordsLicenseForTable->SetLicense(LicenseFile);
// Instantiate Document class to load DOCX and add table
SharedPtr<Document> AddTableToWordDOC = MakeObject<Document>(u"WordDocument.docx");
// Instantiate DocumentBuilder class to manage document content
SharedPtr<DocumentBuilder> TableWriter = MakeObject<DocumentBuilder>(AddTableToWordDOC);
// Mark the start of table
TableWriter->StartTable();
// Insert Row and first Cell inside Word Table
TableWriter->InsertCell();
// Add some text in Table Cell
TableWriter->Write(u"Table Row 1 and Cell 1");
// Add a new Cell inside Row
TableWriter->InsertCell();
// Insert an Image in Word Table Cell
TableWriter->InsertImage(u"image in table.jpg");
// Mark end of Table Row
TableWriter->EndRow();
// Mark end of Word Table creation
TableWriter->EndTable();
// Save the word document with table to docx format
AddTableToWordDOC->Save(u"InsertTableinDocx.docx");
}
};

Daha önce C++ Kullanarak DOCX’e Resim Nasıl Eklenir? gördük. Ancak bu konuda, C++ kullanarak DOCX’e nasıl tablo ekleneceğini öğrendik.

 Türkçe