Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

TestExcelAntSetDoubleCell.java 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.ss.excelant;
  16. import junit.framework.TestCase;
  17. import org.apache.poi.ss.excelant.util.ExcelAntWorkbookUtil;
  18. import org.apache.poi.ss.excelant.util.ExcelAntWorkbookUtilFactory;
  19. public class TestExcelAntSetDoubleCell extends TestCase {
  20. private ExcelAntSetDoubleCell fixture ;
  21. private final String mortgageCalculatorFileName =
  22. "test-data/spreadsheet/mortgage-calculation.xls" ;
  23. private ExcelAntWorkbookUtil util ;
  24. @Override
  25. public void setUp() {
  26. fixture = new ExcelAntSetDoubleCell() ;
  27. util = ExcelAntWorkbookUtilFactory.getInstance(
  28. mortgageCalculatorFileName ) ;
  29. fixture.setWorkbookUtil( util ) ;
  30. }
  31. @Override
  32. public void tearDown() {
  33. fixture = null ;
  34. }
  35. public void testSetDouble() {
  36. String cellId = "'Sheet3'!$A$1" ;
  37. double testValue = 1.1 ;
  38. fixture.setCell( cellId ) ;
  39. fixture.setValue( testValue ) ;
  40. double value = fixture.getCellValue() ;
  41. assertTrue( value > 0 ) ;
  42. assertEquals( testValue, value, 0.0 ) ;
  43. fixture.execute() ;
  44. double setValue = util.getCellAsDouble( cellId ) ;
  45. assertEquals( setValue, testValue, 0.0 ) ;
  46. }
  47. }