apache-poi

How to get datavalidation source for a cell in java using poi?

丶灬走出姿态 提交于 2021-01-29 21:00:34
问题 I have defined a list of valuses my_list in one excel sheet as follow: In another excel sheet, I reference for some cells to that list sothat this list is shown as dropdown in the cell as follows: Using poi, I go throw excel sheet rows/columns and read cells for cell. I get value of cells using method: cell.getStringCellValue() My question is how to get the name of the list my_list from the cell? 回答1: This problem contains multiple different problems. First we need get sheet's data

Apache POI throwing OOM error when trying to password protect modest sized XLSX workbooks (~=80MB)

蹲街弑〆低调 提交于 2021-01-29 20:12:45
问题 using java 8 and apache POI and POI-OOXML 3.14 Here's my method: private static void encryptXlsx(String inputPath, String outputPath, String password) throws IOException, InvalidFormatException, GeneralSecurityException { //create a new workbook Workbook wb = WorkbookFactory.create(new File(inputPath)); //Add password protection and encrypt the file POIFSFileSystem fs = new POIFSFileSystem(); EncryptionInfo info = new EncryptionInfo(EncryptionMode.agile); Encryptor enc = info.getEncryptor();

How to remove extra space between page and footer poi java

孤者浪人 提交于 2021-01-29 17:29:51
问题 I am creating a poi word document . I have setup page margin 0 but their is extra space between bottom and footer image i want to remove this space. I have used this code which did not work addNewPgMar.setLeft(BigInteger.valueOf(0)); addNewPgMar.setRight(BigInteger.valueOf(210)); addNewPgMar.setGutter(BigInteger.valueOf(0)); addNewPgMar.setFooter(BigInteger.valueOf(0)); addNewPgMar.setHeader(BigInteger.valueOf(0)); I want to remove this footer below space which is showing in image. 回答1: Your

Apache POI throwing OOM error when trying to password protect modest sized XLSX workbooks (~=80MB)

穿精又带淫゛_ 提交于 2021-01-29 16:14:21
问题 using java 8 and apache POI and POI-OOXML 3.14 Here's my method: private static void encryptXlsx(String inputPath, String outputPath, String password) throws IOException, InvalidFormatException, GeneralSecurityException { //create a new workbook Workbook wb = WorkbookFactory.create(new File(inputPath)); //Add password protection and encrypt the file POIFSFileSystem fs = new POIFSFileSystem(); EncryptionInfo info = new EncryptionInfo(EncryptionMode.agile); Encryptor enc = info.getEncryptor();

sheet.getDataValidations() returns an empty list when a cell is validated by a sequence on another sheet

和自甴很熟 提交于 2021-01-29 14:15:40
问题 I have a workbook with two sheets: Sheet1 Sheet2 And there is a sequence on Sheet2 at the range of A1 to A5: aa bb cc dd ee And in Sheet1, the cell A1 is validated by the sequence in Sheet2. Excel screenshot However, sheet.getDataValidations() returns an empty list for this case. Did I miss something? public static void main(String[] args) throws Exception { String filePath = "/Users/fujiexiang/ExcelWorkbook.xlsx"; Workbook workbook = WorkbookFactory.create(new FileInputStream(filePath));

IRR in poi return NaN but correct value in excel

久未见 提交于 2021-01-29 12:01:24
问题 When i calculate Irr value use apache/poi i get Double.NaN, but the same inputs in excel i got a negative value. So why they return different value? inputs here: irr(-1.0601017230994111E8,19150.63,44505.08,22997.34,33936.39,27265.92,2127.66,2108.63,886.53,2482.27,4305.12,3421.58,65644.12,1020.51,2659.57,3191.49,20284508.4,1881279.27,11675415.09,7557862.28,921090.46,622104.32,289267.36,183.41,886.53, 0.1) 回答1: For me it gives the #NUM! error in current apache poi 4.1.0 , not NaN . The problem

How to define dynamic cell range for Excel sheet using java?

白昼怎懂夜的黑 提交于 2021-01-29 09:49:12
问题 This is my code: SheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting(); ConditionalFormattingRule rule = sheetCF.createConditionalFormattingRule( "MOD(ROW() - 1, 1) = 0"); PatternFormatting fill = rule.createPatternFormatting(); style.setFillForegroundColor(IndexedColors.BLUE.index); style.setFillPattern(CellStyle.SOLID_FOREGROUND); FontFormatting ffRed = rule.createFontFormatting(); ffRed.setFontColorIndex(IndexedColors.WHITE.index); CellRangeAddress[] regions = {

Apache POI: Force celldata type to be NO formula?

天大地大妈咪最大 提交于 2021-01-29 08:30:25
问题 Adding pure text from a different source, i noticed Apache POI (3.17) automatically assumes a String starting with = is interpreted as a formula. This is usually fine, but how can i make sure that in this special case, the cell is NOT a formula? I assumed after adding the String starting with = , i can just tell Apache POI the type is CellType.STRING : cell.setCellType(CellType.STRING); But this does not yield the expected result, the String is still read as a formula in the output .xlsx file

How to add POI Android in Android Studio?

点点圈 提交于 2021-01-29 08:12:11
问题 I'd like to add POI Android in to Android Studio. The gradle code is this: implementation "com.github.SUPERCILEX.poi-android:poi:$poiVersion" But i only get this message: Could not get unknown property 'poiVersion' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. Could you help me? 回答1: Open your project-level build.gradle file. Add below code snippet: allprojects { repositories { // ... maven { url 'https://jitpack.io' } } } Then, inside

java.net.UnknownHostException Can't Solve in selenium

寵の児 提交于 2021-01-29 07:48:29
问题 Till Yesterday i was using Webdriver Manager it was working sucessfully. but today it is Throwing some UnknownHostException My Dependinces : <dependency> <groupId>io.github.bonigarcia</groupId> <artifactId>webdrivermanager</artifactId> <version>3.0.0</version> <scope>test</scope> </dependency> This is the way i used to open the browser : WebDriverManager.chromedriver().setup(); driver = new ChromeDriver(); I can't find a Perfect Solution but am getting some solution which is not clear can you