Bonjour,
J'ai trouvé cette fonction pour copier un document Excel avec JExcel:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
public static void copieExcel(Workbook w1, WritableWorkbook w2)
	{
		Sheet[] tabsh=null;
		WritableSheet ws=null;
		int sheetrow=0;
		int sheetcol=0;
		Cell ce2=null;
		WritableCell ce3;
		CellFormat format=null;
		CellFeatures cellf=null;
		CellView crowview=null, ccolview=null;
		Range[] tabr;
		Label lab = null;
 
		tabsh=w1.getSheets();
		for(Sheet sh:tabsh)
		{
			ws=w2.createSheet(sh.getName(),w2.getSheets().length);
			sheetrow=sh.getRows();
			sheetcol=sh.getColumns();
 
			for(int i=0;i<sheetcol;i++)
			{
				for(int j=0;j<sheetrow;j++)
				{
					ce2=sh.getCell(i, j);
					format=ce2.getCellFormat();
					cellf=ce2.getCellFeatures();
					try
					{
						ce3=ws.getWritableCell(i,j);
						if(cellf!=null)
						{
							ce3.setCellFeatures(new WritableCellFeatures(cellf));
						}
						if(format!=null)
						{
							ce3.setCellFormat(new WritableCellFormat(format));
						}
					}
					catch(Exception e)
					{
						System.out.println("erreur");
					}
				}
			}
			for(int i=0;i<sheetcol;i++)
			{
				ccolview=sh.getColumnView(i);
				ws.setColumnView(i,ccolview);
			}
			for(int i=0;i<sheetrow;i++)
			{
				crowview=sh.getRowView(i);
				try 
				{
					ws.setRowView(i,crowview);
				} 
				catch (RowsExceededException e) 
				{
						e.printStackTrace();
				}
			}
			tabr=sh.getMergedCells();
			if(tabr.length>0)
			{
				for(Range r:tabr)
				{
					try 
					{
						ws.mergeCells(r.getTopLeft().getColumn(),r.getTopLeft().getRow(),r.getBottomRight().getColumn(),r.getBottomRight().getRow());
					} 
					catch (RowsExceededException e) 
					{
						e.printStackTrace();
					} 
					catch (WriteException e) 
					{
						e.printStackTrace();
					}
				}
			}
			for(int i=0;i<sheetcol;i++)
			{
				for(int j=0;j<sheetrow;j++)
				{
					ce2=sh.getCell(i, j);
					if(!ce2.getType().equals(CellType.EMPTY))
					{
						format=ce2.getCellFormat();
						cellf=ce2.getCellFeatures();
						if(ce2.getType().equals(CellType.LABEL))
						{
							lab=new Label(i,j,ce2.getContents());
							if(cellf!=null)
							{
								lab.setCellFeatures(new WritableCellFeatures(cellf));
							}
							if(format!=null)
							{
								lab.setCellFormat(new WritableCellFormat(format));
							}
							try 
							{
								ws.addCell(lab);
							} 
							catch (RowsExceededException e) 
							{
								e.printStackTrace();
							} catch (WriteException e) 
							{
								e.printStackTrace();
							}
						}
						else
						{
							cellf=null;
							format=null;
							lab=new Label(i,j,null);
							if(cellf!=null)
							{
								lab.setCellFeatures(new WritableCellFeatures(cellf));
							}
							if(format!=null)
							{
								lab.setCellFormat(new WritableCellFormat(format));
							}
							try 
							{
								ws.addCell(lab);
							} 
							catch (RowsExceededException e) 
							{
								e.printStackTrace();
							} catch (WriteException e) 
							{
								e.printStackTrace();
							}
						}
					}
				}
			}
		}
	}
Cela marche sauf pour les maccros qui ne sont pas copiés et j'ai ceci qui s'affiche:

Warning: TBD on sheet "ACS-GC-F-001" not supported - omitting
Warning: TBD on sheet "ACS-GC-F-001" not supported - omitting

Pouvez vous me dire quoi rajouter svp afin que les maccros soient aussi copiés avec ce code?

J'ai fais ceci pour copier le contenu avec les maccros:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
w1 = Workbook.getWorkbook(inputWorkbook);
WritableWorkbook w2 = Workbook.createWorkbook(outputWorkbook, w1);
Cependant je ne peux pas rajouter de contenu...