Skip to content

Commit a7dc0b0

Browse files
committed
Added New Examples
Added New Examples
1 parent 4ef1656 commit a7dc0b0

File tree

6 files changed

+688
-329
lines changed

6 files changed

+688
-329
lines changed

Examples.xml

Lines changed: 573 additions & 329 deletions
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright 2001-2013 Aspose Pty Ltd. All Rights Reserved.
3+
*
4+
* This file is part of Aspose.Cells. The source code in this file
5+
* is only intended as a supplement to the documentation, and is provided
6+
* "as is", without warranty of any kind, either expressed or implied.
7+
*/
8+
9+
package programmersguide.asposecells.workingwithdata.addonfeatures.mergingunmergingcells.mergingcellsinworksheet.java;
10+
11+
import com.aspose.cells.*;
12+
13+
public class MergingCellsInWorksheet
14+
{
15+
public static void main(String[] args) throws Exception
16+
{
17+
// The path to the documents directory.
18+
String dataDir = "src/programmersguide/asposecells/workingwithdata/addonfeatures/mergingunmergingcells/mergingcellsinworksheet/data/";
19+
20+
//Create a Workbook.
21+
Workbook wbk=new Workbook();
22+
23+
//Create a Worksheet and get the first sheet.
24+
Worksheet worksheet = wbk.getWorksheets().get(0);
25+
26+
//Create a Cells object to fetch all the cells.
27+
Cells cells = worksheet.getCells();
28+
29+
//Merge some Cells (C6:E7) into a single C6 Cell.
30+
cells.merge(5,2,2,3);
31+
32+
//Input data into C6 Cell.
33+
worksheet.getCells().get(5,2).setValue("This is my value");
34+
35+
//Create a Style object to fetch the Style of C6 Cell.
36+
Style style = worksheet.getCells().get(5,2).getStyle();
37+
38+
//Create a Font object
39+
Font font = style.getFont();
40+
41+
//Set the name.
42+
font.setName("Times New Roman");
43+
44+
//Set the font size.
45+
font.setSize(18);
46+
47+
//Set the font color
48+
font.setColor(Color.getBlue());
49+
50+
//Bold the text
51+
font.setBold(true);
52+
53+
//Make it italic
54+
font.setItalic(true);
55+
56+
//Set the backgrond color of C6 Cell to Red
57+
style.setForegroundColor(Color.getRed());
58+
style.setPattern(BackgroundType.SOLID);
59+
60+
//Apply the Style to C6 Cell.
61+
cells.get(5,2).setStyle(style);
62+
63+
//Save the Workbook.
64+
wbk.save(dataDir + "mergingcells.xls");
65+
66+
// Print message
67+
System.out.println("Process completed successfully");
68+
}
69+
}
70+
71+
72+
73+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2001-2013 Aspose Pty Ltd. All Rights Reserved.
3+
*
4+
* This file is part of Aspose.Cells. The source code in this file
5+
* is only intended as a supplement to the documentation, and is provided
6+
* "as is", without warranty of any kind, either expressed or implied.
7+
*/
8+
9+
package programmersguide.asposecells.workingwithdata.addonfeatures.mergingunmergingcells.unmergingthemergedcells.java;
10+
11+
import com.aspose.cells.*;
12+
13+
public class UnMergingCellsInWorksheet
14+
{
15+
public static void main(String[] args) throws Exception
16+
{
17+
// The path to the documents directory.
18+
String dataDir = "src/programmersguide/asposecells/workingwithdata/addonfeatures/mergingunmergingcells/unmergingthemergedcells/data/";
19+
20+
//Create a Workbook.
21+
Workbook wbk=new Workbook(dataDir + "mergingcells.xls");
22+
23+
//Create a Worksheet and get the first sheet.
24+
Worksheet worksheet = wbk.getWorksheets().get(0);
25+
26+
//Create a Cells object to fetch all the cells.
27+
Cells cells = worksheet.getCells();
28+
29+
//Unmerge the cells.
30+
cells.unMerge(5,2,2,3);
31+
32+
//Save the file.
33+
wbk.save(dataDir + "unmergingcells.xls");
34+
35+
// Print message
36+
System.out.println("Process completed successfully");
37+
}
38+
}
39+
40+
41+
42+

0 commit comments

Comments
 (0)