This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a new XWPFDocument (representing a DOCX file) | |
XWPFDocument document = new XWPFDocument(); | |
// Create a paragraph in the document | |
XWPFParagraph paragraph = document.createParagraph(); | |
XWPFRun run = paragraph.createRun(); | |
// Write the text to the paragraph | |
run.setText("Hello, World!"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import java.io.FileInputStream; | |
import org.docx4j.openpackaging.packages.WordprocessingMLPackage; | |
import org.docx4j.wml.ObjectFactory; | |
import org.docx4j.dml.wordprocessingDrawing.Inline; | |
import org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage; | |
import org.docx4j.wml.P; | |
public class InsertImageExample { | |
public static void main(String[] args) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load the existing document from the file | |
WordprocessingMLPackage wordPackage = WordprocessingMLPackage.load(new java.io.File("existing.docx")); | |
// Get the main document part | |
MainDocumentPart documentPart = wordPackage.getMainDocumentPart(); | |
// Get all the text elements (this will retrieve all the Text objects in the document) | |
List<Object> texts = documentPart.getJAXBNodesViaXPath("//w:t", true); | |
// Modify the text in the first paragraph (or whichever text you want to modify) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.docx4j.openpackaging.packages.WordprocessingMLPackage; | |
import org.docx4j.wml.ObjectFactory; | |
import org.docx4j.wml.P; | |
import org.docx4j.wml.Text; | |
public class Docx4JExample { | |
public static void main(String[] args) { | |
try { | |
// Create a new WordprocessingMLPackage (Word document) | |
WordprocessingMLPackage wordPackage = WordprocessingMLPackage.createPackage(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using MimeKit; | |
using Org.BouncyCastle.Crypto; | |
using Org.BouncyCastle.Security; | |
using System.Security.Cryptography.X509Certificates; | |
var encryptedMessage = ... // Load or receive the encrypted message | |
// Load the recipient's private certificate and key | |
var privateKey = new X509Certificate2("path-to-recipient-private-cert.pfx", "password"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using MimeKit; | |
using System.IO; | |
var message = new MimeMessage(); | |
// Set the sender | |
message.From.Add(new MailboxAddress("Your Name", "[email protected]")); | |
// Set the recipient | |
message.To.Add(new MailboxAddress("Recipient Name", "[email protected]")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using MimeKit; | |
var message = new MimeMessage(); | |
// Set the sender | |
message.From.Add(new MailboxAddress("Your Name", "[email protected]")); | |
// Set the recipient | |
message.To.Add(new MailboxAddress("Recipient Name", "[email protected]")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using ExcelDataReader; | |
using System.Data; | |
using System.IO; | |
class Program | |
{ | |
static void Main() | |
{ | |
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from openpyxl import load_workbook | |
# Load the workbook | |
workbook = load_workbook('example.xlsx') | |
# Select the active sheet | |
sheet = workbook.active | |
# Modify a cell value | |
sheet['A1'] = 'Updated Name' |