Skip to content

Commit 88cedd1

Browse files
Merge pull request #18 from saqibmasood/master
Add examples
2 parents ce5bbce + 7067d78 commit 88cedd1

File tree

7 files changed

+111
-1
lines changed

7 files changed

+111
-1
lines changed

Examples/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<dependency>
1515
<groupId>com.aspose</groupId>
1616
<artifactId>aspose-cells</artifactId>
17-
<version>8.4.2</version>
17+
<version>8.6.0</version>
1818
</dependency>
1919
</dependencies>
2020
<repositories>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2001-2015 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+
package com.aspose.cells.examples.articles;
9+
10+
import com.aspose.cells.*;
11+
import com.aspose.cells.examples.Utils;
12+
13+
public class AssignMacroToFormControl {
14+
15+
public static void main(String[] args) throws Exception {
16+
// The path to the documents directory.
17+
String dataDir = Utils.getDataDir(AssignMacroToFormControl.class);
18+
19+
Workbook workbook = new Workbook();
20+
Worksheet sheet = workbook.getWorksheets().get(0);
21+
22+
int moduleIdx = workbook.getVbaProject().getModules().add(sheet);
23+
VbaModule module = workbook.getVbaProject().getModules().get(moduleIdx);
24+
module.setCodes("Sub ShowMessage()" + "\r\n" +
25+
" MsgBox \"Welcome to Aspose!\"" + "\r\n" +
26+
"End Sub");
27+
28+
Button button = (Button) sheet.getShapes().addShape(MsoDrawingType.BUTTON, 2, 0, 2, 0, 28, 80);
29+
button.setPlacement(PlacementType.FREE_FLOATING);
30+
button.getFont().setName("Tahoma");
31+
button.getFont().setBold(true);
32+
button.getFont().setColor(Color.getBlue());
33+
button.setText("Aspose");
34+
35+
workbook.save(dataDir + "Output.xlsm");
36+
37+
System.out.println("File saved");
38+
}
39+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2001-2015 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+
package com.aspose.cells.examples.articles;
9+
10+
import com.aspose.cells.HtmlSaveOptions;
11+
import com.aspose.cells.Workbook;
12+
import com.aspose.cells.examples.Utils;
13+
14+
public class HtmlExportFrameScripts {
15+
16+
public static void main(String[] args) throws Exception {
17+
// The path to the documents directory.
18+
String dataDir = Utils.getDataDir(HtmlExportFrameScripts.class);
19+
20+
// Open the required workbook to convert
21+
Workbook w = new Workbook(dataDir + "Sample1.xlsx");
22+
23+
// Disable exporting frame scripts and document properties
24+
HtmlSaveOptions options = new HtmlSaveOptions();
25+
options.setExportFrameScriptsAndProperties(false);
26+
27+
// Save workbook as HTML
28+
w.save(dataDir + "output.html", options);
29+
30+
System.out.println("File saved");
31+
}
32+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2001-2015 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+
package com.aspose.cells.examples.articles;
9+
10+
import com.aspose.cells.MetadataOptions;
11+
import com.aspose.cells.MetadataType;
12+
import com.aspose.cells.Workbook;
13+
import com.aspose.cells.WorkbookMetadata;
14+
import com.aspose.cells.examples.Utils;
15+
16+
public class UsingWorkbookMetadata {
17+
18+
public static void main(String[] args) throws Exception {
19+
// The path to the documents directory.
20+
String dataDir = Utils.getDataDir(UsingWorkbookMetadata.class);
21+
22+
23+
// Open Workbook metadata
24+
MetadataOptions options = new MetadataOptions(MetadataType.DOCUMENT_PROPERTIES);
25+
WorkbookMetadata meta = new WorkbookMetadata(dataDir + "Sample1.xlsx", options);
26+
27+
// Set some properties
28+
meta.getCustomDocumentProperties().add("test", "test");
29+
30+
// Save the metadata info
31+
meta.save(dataDir + "Sample2.xlsx");
32+
33+
// Open the workbook
34+
Workbook w = new Workbook(dataDir + "Sample2.xlsx");
35+
36+
// Read document property
37+
System.out.println(w.getCustomDocumentProperties().get("test"));
38+
}
39+
}

Examples/src/main/resources/com/aspose/cells/examples/articles/AssignMacroToFormControl/.gitignore

Whitespace-only changes.
Binary file not shown.

0 commit comments

Comments
 (0)