mirror of https://github.com/alibaba/easyexcel
Jiaju Zhuang
4 years ago
23 changed files with 450 additions and 497 deletions
@ -0,0 +1,2 @@
|
||||
lombok.toString.callSuper = CALL |
||||
lombok.equalsAndHashCode.callSuper= CALL |
@ -0,0 +1,139 @@
|
||||
package com.alibaba.excel.metadata; |
||||
|
||||
import lombok.Data; |
||||
import org.apache.poi.ss.usermodel.ClientAnchor; |
||||
import org.apache.poi.util.Internal; |
||||
|
||||
/** |
||||
* A client anchor is attached to an excel worksheet. It anchors against |
||||
* absolute coordinates, a top-left cell and fixed height and width, or |
||||
* a top-left and bottom-right cell, depending on the {@link ClientAnchorData.AnchorType}: |
||||
* <ol> |
||||
* <li> {@link ClientAnchor.AnchorType#DONT_MOVE_AND_RESIZE} == absolute top-left coordinates and width/height, no |
||||
* cell references |
||||
* <li> {@link ClientAnchor.AnchorType#MOVE_DONT_RESIZE} == fixed top-left cell reference, absolute width/height |
||||
* <li> {@link ClientAnchor.AnchorType#MOVE_AND_RESIZE} == fixed top-left and bottom-right cell references, dynamic |
||||
* width/height |
||||
* </ol> |
||||
* Note this class only reports the current values for possibly calculated positions and sizes. |
||||
* If the sheet row/column sizes or positions shift, this needs updating via external calculations. |
||||
* |
||||
* @author Jiaju Zhuang |
||||
*/ |
||||
@Data |
||||
public class ClientAnchorData { |
||||
|
||||
/** |
||||
* The x coordinate within the first cell. |
||||
*/ |
||||
private int dx1; |
||||
|
||||
/** |
||||
* The y coordinate within the first cell. |
||||
*/ |
||||
private int dy1; |
||||
|
||||
/** |
||||
* The x coordinate within the second cell. |
||||
*/ |
||||
private int dx2; |
||||
|
||||
/** |
||||
* The y coordinate within the second cell |
||||
*/ |
||||
private int dy2; |
||||
|
||||
/** |
||||
* 0-based column of the first cell. |
||||
*/ |
||||
private short col1; |
||||
|
||||
/** |
||||
* 0-based row of the first cell. |
||||
*/ |
||||
private int row1; |
||||
|
||||
/** |
||||
* 0-based column of the second cell. |
||||
*/ |
||||
private short col2; |
||||
|
||||
/** |
||||
* 0-based row of the second cell. |
||||
*/ |
||||
private int row2; |
||||
/** |
||||
* anchor type |
||||
*/ |
||||
private AnchorType anchorType; |
||||
|
||||
public enum AnchorType { |
||||
/** |
||||
* Move and Resize With Anchor Cells (0) |
||||
* <p> |
||||
* Specifies that the current drawing shall move and |
||||
* resize to maintain its row and column anchors (i.e. the |
||||
* object is anchored to the actual from and to row and column) |
||||
* </p> |
||||
*/ |
||||
MOVE_AND_RESIZE(0), |
||||
|
||||
/** |
||||
* Don't Move but do Resize With Anchor Cells (1) |
||||
* <p> |
||||
* Specifies that the current drawing shall not move with its |
||||
* row and column, but should be resized. This option is not normally |
||||
* used, but is included for completeness. |
||||
* </p> |
||||
* Note: Excel has no setting for this combination, nor does the ECMA standard. |
||||
*/ |
||||
DONT_MOVE_DO_RESIZE(1), |
||||
|
||||
/** |
||||
* Move With Cells but Do Not Resize (2) |
||||
* <p> |
||||
* Specifies that the current drawing shall move with its |
||||
* row and column (i.e. the object is anchored to the |
||||
* actual from row and column), but that the size shall remain absolute. |
||||
* </p> |
||||
* <p> |
||||
* If additional rows/columns are added between the from and to locations of the drawing, |
||||
* the drawing shall move its to anchors as needed to maintain this same absolute size. |
||||
* </p> |
||||
*/ |
||||
MOVE_DONT_RESIZE(2), |
||||
|
||||
/** |
||||
* Do Not Move or Resize With Underlying Rows/Columns (3) |
||||
* <p> |
||||
* Specifies that the current start and end positions shall |
||||
* be maintained with respect to the distances from the |
||||
* absolute start point of the worksheet. |
||||
* </p> |
||||
* <p> |
||||
* If additional rows/columns are added before the |
||||
* drawing, the drawing shall move its anchors as needed |
||||
* to maintain this same absolute position. |
||||
* </p> |
||||
*/ |
||||
DONT_MOVE_AND_RESIZE(3); |
||||
|
||||
public final short value; |
||||
|
||||
// disallow non-sequential enum instance creation
|
||||
private AnchorType(int value) { |
||||
this.value = (short)value; |
||||
} |
||||
|
||||
/** |
||||
* return the AnchorType corresponding to the code |
||||
* |
||||
* @param value the anchor type code |
||||
* @return the anchor type enum |
||||
*/ |
||||
@Internal |
||||
public static ClientAnchorData.AnchorType byId(int value) { |
||||
return values()[value]; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,28 @@
|
||||
package com.alibaba.excel.metadata; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* TODO |
||||
* |
||||
* @author Jiaju Zhuang |
||||
*/ |
||||
@Data |
||||
public class CommentData { |
||||
/** |
||||
* Row index |
||||
*/ |
||||
private Integer rowIndex; |
||||
/** |
||||
* Column index |
||||
*/ |
||||
private Integer columnIndex; |
||||
/** |
||||
* Name of the original comment author |
||||
*/ |
||||
private String author; |
||||
/** |
||||
* rich text string |
||||
*/ |
||||
private RichTextStringData richTextStringData; |
||||
} |
@ -0,0 +1,20 @@
|
||||
package com.alibaba.excel.metadata; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* data format |
||||
* |
||||
* @author Jiaju Zhuang |
||||
*/ |
||||
@Data |
||||
public class DataFormat { |
||||
/** |
||||
* index |
||||
*/ |
||||
private Short index; |
||||
/** |
||||
* format |
||||
*/ |
||||
private String format; |
||||
} |
@ -0,0 +1,16 @@
|
||||
package com.alibaba.excel.metadata; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* formula |
||||
* |
||||
* @author Jiaju Zhuang |
||||
*/ |
||||
@Data |
||||
public class FormulaData { |
||||
/** |
||||
* formula |
||||
*/ |
||||
private String formulaValue; |
||||
} |
@ -0,0 +1,10 @@
|
||||
package com.alibaba.excel.metadata; |
||||
|
||||
/** |
||||
* TODO |
||||
* |
||||
* @author Jiaju Zhuang |
||||
*/ |
||||
public class HyperlinkData { |
||||
|
||||
} |
@ -0,0 +1,58 @@
|
||||
package com.alibaba.excel.metadata; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* image |
||||
* |
||||
* @author Jiaju Zhuang |
||||
*/ |
||||
@Data |
||||
public class ImageData extends ClientAnchorData { |
||||
|
||||
/** |
||||
* image |
||||
*/ |
||||
private byte[] image; |
||||
|
||||
/** |
||||
* image type |
||||
*/ |
||||
private ImageType imageType; |
||||
|
||||
public enum ImageType { |
||||
/** |
||||
* Extended windows meta file |
||||
*/ |
||||
PICTURE_TYPE_EMF(2), |
||||
/** |
||||
* Windows Meta File |
||||
*/ |
||||
PICTURE_TYPE_WMF(3), |
||||
/** |
||||
* Mac PICT format |
||||
*/ |
||||
PICTURE_TYPE_PICT(4), |
||||
/** |
||||
* JPEG format |
||||
*/ |
||||
PICTURE_TYPE_JPEG(5), |
||||
/** |
||||
* PNG format |
||||
*/ |
||||
PICTURE_TYPE_PNG(6), |
||||
/** |
||||
* Device independent bitmap |
||||
*/ |
||||
PICTURE_TYPE_DIB(7), |
||||
|
||||
; |
||||
|
||||
public final int value; |
||||
|
||||
ImageType(int value) { |
||||
this.value = value; |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,13 @@
|
||||
package com.alibaba.excel.metadata; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* TODO |
||||
* |
||||
* @author Jiaju Zhuang |
||||
*/ |
||||
@Data |
||||
public class ReadCellData<T> extends CellData<T>{ |
||||
|
||||
} |
@ -0,0 +1,59 @@
|
||||
package com.alibaba.excel.metadata; |
||||
|
||||
import java.util.List; |
||||
|
||||
import com.alibaba.excel.util.ListUtils; |
||||
import com.alibaba.excel.write.metadata.style.WriteFont; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
/** |
||||
* TODO |
||||
* |
||||
* @author Jiaju Zhuang |
||||
*/ |
||||
@Data |
||||
@NoArgsConstructor |
||||
public class RichTextStringData { |
||||
private String textString; |
||||
private WriteFont writeFont; |
||||
private List<IntervalFont> intervalFontList; |
||||
|
||||
public RichTextStringData(String textString) { |
||||
this.textString = textString; |
||||
} |
||||
|
||||
@Data |
||||
@AllArgsConstructor |
||||
public static class IntervalFont { |
||||
private Integer startIndex; |
||||
private Integer endIndex; |
||||
private WriteFont writeFont; |
||||
} |
||||
|
||||
/** |
||||
* Applies a font to the specified characters of a string. |
||||
* |
||||
* @param startIndex The start index to apply the font to (inclusive) |
||||
* @param endIndex The end index to apply to font to (exclusive) |
||||
* @param writeFont The font to use. |
||||
*/ |
||||
public void applyFont(int startIndex, int endIndex, WriteFont writeFont) { |
||||
if (intervalFontList == null) { |
||||
intervalFontList = ListUtils.newArrayList(); |
||||
} |
||||
intervalFontList.add(new IntervalFont(startIndex, endIndex, writeFont)); |
||||
} |
||||
|
||||
/** |
||||
* Sets the font of the entire string. |
||||
* |
||||
* @param writeFont The font to use. |
||||
*/ |
||||
public void applyFont(WriteFont writeFont) { |
||||
this.writeFont = writeFont; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,42 @@
|
||||
package com.alibaba.excel.metadata; |
||||
|
||||
import java.util.Date; |
||||
|
||||
import com.alibaba.excel.enums.CellDataTypeEnum; |
||||
import com.alibaba.excel.write.metadata.style.WriteCellStyle; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* TODO |
||||
* |
||||
* @author Jiaju Zhuang |
||||
*/ |
||||
@Data |
||||
public class WriteCellData<T> extends CellData<T> { |
||||
/** |
||||
* Support only when writing.{@link CellDataTypeEnum#DATE} |
||||
*/ |
||||
private Date dateValue; |
||||
/** |
||||
* {@link CellDataTypeEnum#IMAGE} |
||||
*/ |
||||
private ImageData imageDataValue; |
||||
/** |
||||
* rich text.{@link CellDataTypeEnum#RICH_TEXT_STRING} |
||||
*/ |
||||
private RichTextStringData richTextStringDataValue; |
||||
|
||||
/** |
||||
* comment |
||||
*/ |
||||
private CommentData commentData; |
||||
/** |
||||
* hyper link |
||||
*/ |
||||
private HyperlinkData hyperlinkData; |
||||
/** |
||||
* sytle |
||||
*/ |
||||
private WriteCellStyle writeCellStyle; |
||||
} |
Loading…
Reference in new issue