I\'m creating an excel (.xlsx) file using poi (java). After I create the excel file I see the excel file Author as \"Apache POI\". Is there any way to change that?
H
Not a direct answer but in case anyone needs to do this in NPOI (the .NET port of POI) here is the extension method I came up with ... it's basically what Olivier suggested - only implemented in C#:
///
/// Sets the author of this workbook.
///
///
///
public static void SetAuthor(this IWorkbook workbook, string author)
{
if (workbook is NPOI.XSSF.UserModel.XSSFWorkbook)
{
var xssfWorkbook = workbook as NPOI.XSSF.UserModel.XSSFWorkbook;
var xmlProps = xssfWorkbook.GetProperties();
var coreProps = xmlProps.CoreProperties;
coreProps.Creator = author;
return;
}
if (workbook is NPOI.HSSF.UserModel.HSSFWorkbook)
{
var hssfWorkbook = workbook as NPOI.HSSF.UserModel.HSSFWorkbook;
var summaryInfo = hssfWorkbook.SummaryInformation;
if (summaryInfo != null)
{
summaryInfo.Author = author;
return;
}
var newDocInfo = NPOI.HPSF.PropertySetFactory.CreateDocumentSummaryInformation();
var newInfo = NPOI.HPSF.PropertySetFactory.CreateSummaryInformation();
newInfo.Author = author;
hssfWorkbook.DocumentSummaryInformation = newDocInfo;
hssfWorkbook.SummaryInformation = newInfo;
return;
}
}