git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1925420 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2025-05-05 18:43:08 +00:00
parent 9e30ffc0de
commit c37b4ee0d5
2 changed files with 18 additions and 1 deletions

View File

@ -266,7 +266,7 @@ public final class AnalysisToolPak implements UDFFinder {
* @throws IllegalArgumentException if the function is unknown or already registered.
* @since 3.8 beta6
*/
public static void registerFunction(String name, FreeRefFunction func){
public static void registerFunction(String name, FreeRefFunction func) {
AnalysisToolPak inst = (AnalysisToolPak)instance;
if(!isATPFunction(name)) {
FunctionMetadata metaData = FunctionMetadataRegistry.getFunctionByName(name);

View File

@ -26,6 +26,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
import org.apache.poi.hssf.record.CountryRecord;
import org.apache.poi.hssf.record.FontRecord;
import org.apache.poi.hssf.record.RecalcIdRecord;
@ -170,4 +171,20 @@ final class TestWorkbook {
int newRecordsCount = iwb.getNumRecords();
assertEquals(oldRecordsCount, newRecordsCount, "records count after getWriteAccess");
}
@Test
void testSetUserName() throws IOException {
try (HSSFWorkbook wb = new HSSFWorkbook()) {
InternalWorkbook iwb = wb.getInternalWorkbook();
iwb.getWriteAccess().setUsername("username");
assertEquals("username", iwb.getWriteAccess().getUsername());
try (UnsynchronizedByteArrayOutputStream os = UnsynchronizedByteArrayOutputStream.builder().get()) {
wb.write(os);
try (HSSFWorkbook wb2 = new HSSFWorkbook(os.toInputStream())) {
InternalWorkbook iwb2 = wb2.getInternalWorkbook();
assertEquals("username", iwb2.getWriteAccess().getUsername());
}
}
}
}
}