// Load password-protected Excel fileWorkBook protectedWorkBook = WorkBook.Load("protected.xlsx", "myPassword123");// Work with the workbook normallyWorkSheet sheet = protectedWorkBook.DefaultWorkSheet;sheet["B2"].Value = "Updated secure data";// Save with password protectionprotectedWorkBook.SaveAs("updated_protected.xlsx");
// Load password-protected Excel file
WorkBook protectedWorkBook = WorkBook.Load("protected.xlsx", "myPassword123");
// Work with the workbook normally
WorkSheet sheet = protectedWorkBook.DefaultWorkSheet;
sheet["B2"].Value = "Updated secure data";
// Save with password protection
protectedWorkBook.SaveAs("updated_protected.xlsx");
' Load password-protected Excel fileDim protectedWorkBook AsWorkBook = WorkBook.Load("protected.xlsx", "myPassword123")' Work with the workbook normallyDim sheet AsWorkSheet = protectedWorkBook.DefaultWorkSheetsheet("B2").Value = "Updated secure data"' Save with password protectionprotectedWorkBook.SaveAs("updated_protected.xlsx")
' Load password-protected Excel file
Dim protectedWorkBook As WorkBook = WorkBook.Load("protected.xlsx", "myPassword123")
' Work with the workbook normally
Dim sheet As WorkSheet = protectedWorkBook.DefaultWorkSheet
sheet("B2").Value = "Updated secure data"
' Save with password protection
protectedWorkBook.SaveAs("updated_protected.xlsx")
// Loading from byte arraybyte[] excelBytes = File.ReadAllBytes("sample.xlsx");WorkBook workBookFromBytes = WorkBook.FromByteArray(excelBytes);// Loading from streamusing (FileStream stream = new FileStream("sample.xlsx", FileMode.Open)){ WorkBook workBookFromStream = WorkBook.FromStream(stream); // Process the workbook var sheet = workBookFromStream.DefaultWorkSheet;Console.WriteLine($"Sheet has {sheet.RowCount} rows");}// Loading from MemoryStream (common in web applications)using (MemoryStream memStream = new MemoryStream(excelBytes)){ WorkBook workBookFromMemory = WorkBook.FromStream(memStream);}
// Loading from byte array
byte[] excelBytes = File.ReadAllBytes("sample.xlsx");
WorkBook workBookFromBytes = WorkBook.FromByteArray(excelBytes);
// Loading from stream
using (FileStream stream = new FileStream("sample.xlsx", FileMode.Open))
{
WorkBook workBookFromStream = WorkBook.FromStream(stream);
// Process the workbook
var sheet = workBookFromStream.DefaultWorkSheet;
Console.WriteLine($"Sheet has {sheet.RowCount} rows");
}
// Loading from MemoryStream (common in web applications)
using (MemoryStream memStream = new MemoryStream(excelBytes))
{
WorkBook workBookFromMemory = WorkBook.FromStream(memStream);
}
' Loading from byte arrayDim excelBytes AsByte() = File.ReadAllBytes("sample.xlsx")Dim workBookFromBytes AsWorkBook = WorkBook.FromByteArray(excelBytes)' Loading from streamUsing stream As New FileStream("sample.xlsx", FileMode.Open) Dim workBookFromStream AsWorkBook = WorkBook.FromStream(stream) ' Process the workbook Dim sheet = workBookFromStream.DefaultWorkSheetConsole.WriteLine($"Sheet has {sheet.RowCount} rows")EndUsing' Loading from MemoryStream (common in web applications)Using memStream As New MemoryStream(excelBytes) Dim workBookFromMemory AsWorkBook = WorkBook.FromStream(memStream)EndUsing
' Loading from byte array
Dim excelBytes As Byte() = File.ReadAllBytes("sample.xlsx")
Dim workBookFromBytes As WorkBook = WorkBook.FromByteArray(excelBytes)
' Loading from stream
Using stream As New FileStream("sample.xlsx", FileMode.Open)
Dim workBookFromStream As WorkBook = WorkBook.FromStream(stream)
' Process the workbook
Dim sheet = workBookFromStream.DefaultWorkSheet
Console.WriteLine($"Sheet has {sheet.RowCount} rows")
End Using
' Loading from MemoryStream (common in web applications)
Using memStream As New MemoryStream(excelBytes)
Dim workBookFromMemory As WorkBook = WorkBook.FromStream(memStream)
End Using
Can IronXL preserve relationships between tables in a `DataSet`?
Yes, when loading a `DataSet` with multiple related tables using IronXL, separate worksheets are created, and table relationships are maintained through consistent key values.