Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add update row and update column functions and fix Row values field type #10

Merged
merged 2 commits into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The `microsoft.excel` is a [Ballerina](https://ballerina.io/) connector for Micr
This connector provides operations for connecting and interacting with Microsoft Graph API Excel endpoints over the network.
For more information about configuration and operations, go to the module.

- [`microsoft.excel`](https://docs.central.ballerina.io/ballerinax/microsoft.excel/latest).
- [`microsoft.excel`](https://docs.central.ballerina.io/ballerinax/microsoft.excel/1.0.2).

# Building from the Source
## Setting Up the Prerequisites
Expand Down
2 changes: 1 addition & 1 deletion excel/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
org= "ballerinax"
name= "microsoft.excel"
version= "1.0.1"
version= "1.0.2"
license= ["Apache-2.0"]
authors = ["Ballerina"]
keywords = ["microsoft", "excel", "workbook", "worksheet", "sheets"]
Expand Down
14 changes: 7 additions & 7 deletions excel/Package.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Connects to Microsoft Excel from Ballerina

### Package Overview
#### Compatibility
| | Version |
|------------------------------------------------------------------------------------|-----------------------|
| Ballerina Language Version | **Swan Lake Alpha 5** |
| [Microsoft Graph API](https://docs.microsoft.com/en-us/graph/overview) Version | **v1.0** |

The `microsoft.excel` is a [Ballerina](https://ballerina.io/) connector for Microsoft Excel.

This package provides the capability to easily access Microsoft Excel.
This package provides the capability to perform CRUD operations in Microsoft Excel worksheet table, and chart.

#### Compatibility
| | Version |
|------------------------------------------------------------------------|-----------------------|
| Ballerina Language | **Swan Lake Alpha5** |
| [Microsoft Graph API](https://docs.microsoft.com/en-us/graph/overview) | **v1.0** |

### Report Issues

Expand Down
125 changes: 92 additions & 33 deletions excel/client.bal

Large diffs are not rendered by default.

44 changes: 36 additions & 8 deletions excel/tests/test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function testUpdateTable() {
}
}

int rowInputIndex = 0;
int rowInputIndex = 1;

@test:Config {dependsOn: [testUpdateTable]}
function testCreateRow() {
Expand All @@ -189,14 +189,28 @@ function testListRows() {
log:printInfo("excelClient -> listRows()");
Row[]|error response = excelClient->listRows(workBookId, worksheetName, tableName);
if (response is Row[]) {
int responseIndex = response[0].index;
int responseIndex = response[1].index;
test:assertEquals(responseIndex, rowInputIndex, "Found 0 rows");
} else {
test:assertFail(response.toString());
}
}

@test:Config {dependsOn: [testListRows]}
@test:Config {dependsOn: [testCreateRow]}
function testUpdateRow() {
runtime:sleep(5);
string value = "testValue";
log:printInfo("excelClient -> updateRow()");
Row|error response = excelClient->updateRow(workBookId, worksheetName, tableName, rowInputIndex, [[(), (), value]]);
if (response is Row) {
json updatedValue = response.values[0][2];
test:assertEquals(updatedValue.toString(), value, "Row is not updated");
} else {
test:assertFail(response.toString());
}
}

@test:Config {dependsOn: [testUpdateRow]}
function testDeleteRow() {
log:printInfo("excelClient -> deleteRow()");
error? response = excelClient->deleteRow(workBookId, worksheetName, tableName, rowInputIndex);
Expand All @@ -205,9 +219,9 @@ function testDeleteRow() {
}
}

int columnInputIndex = 3;
int columnInputIndex = 2;

@test:Config {dependsOn: [testUpdateTable]}
@test:Config {dependsOn: [testDeleteRow]}
function testCreateColumn() {
log:printInfo("excelClient -> createColumn()");
Column|error response = excelClient->createColumn(workBookId, worksheetName, tableName, [["a3"], ["c3"], ["aa"]],
Expand All @@ -225,14 +239,28 @@ function testListColumn() {
log:printInfo("excelClient -> listColumns()");
Column[]|error response = excelClient->listColumns(workBookId, worksheetName, tableName);
if (response is Column[]) {
int responseIndex = response[0].index;
test:assertEquals(responseIndex, rowInputIndex, "Found 0 columns");
int responseIndex = response[2].index;
test:assertEquals(responseIndex, columnInputIndex, "Found 0 columns");
} else {
test:assertFail(response.toString());
}
}

@test:Config {dependsOn: [testCreateColumn]}
function testUpdateColumn() {
runtime:sleep(5);
string value = "testName";
log:printInfo("excelClient -> updateColumn()");
Column|error response = excelClient->updateColumn(workBookId, worksheetName, tableName, columnInputIndex, [[()], [()], [value]]);
if (response is Column) {
json updatedValue = response.values[2][0];
test:assertEquals(updatedValue.toString(), value, "Column is not updated");
} else {
test:assertFail(response.toString());
}
}

@test:Config {dependsOn: [testListColumn]}
@test:Config {dependsOn: [testUpdateColumn]}
function testDeleteColumn() {
log:printInfo("excelClient -> deleteColumn()");
error? response = excelClient->deleteColumn(workBookId, worksheetName, tableName, columnInputIndex);
Expand Down
6 changes: 3 additions & 3 deletions excel/types.bal
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public type Cell record {
int rowIndex;
json text;
json valueTypes;
json values;
json[][] values;
};

# Represents the Excel application that manages the workbook.
Expand Down Expand Up @@ -128,7 +128,7 @@ public type Table record {
@display {label: "Row"}
public type Row record {
int index;
json values;
json[][] values;
};

# Chart object in a workbook.
Expand Down Expand Up @@ -168,7 +168,7 @@ public type Column record {
string id;
string name?;
int index;
json values;
json[][] values;
};

# Specifies the calculation type to use in the workbook.
Expand Down
16 changes: 16 additions & 0 deletions samples/add_chart.bal
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
//
// WSO2 Inc. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/log;
import ballerinax/microsoft.excel;

Expand Down
16 changes: 16 additions & 0 deletions samples/add_table.bal
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
//
// WSO2 Inc. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/log;
import ballerinax/microsoft.excel;

Expand Down
16 changes: 16 additions & 0 deletions samples/add_worksheet.bal
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
//
// WSO2 Inc. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/log;
import ballerinax/microsoft.excel;

Expand Down
16 changes: 16 additions & 0 deletions samples/calculate_workbook_application.bal
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
//
// WSO2 Inc. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/log;
import ballerinax/microsoft.excel;

Expand Down
18 changes: 17 additions & 1 deletion samples/create_column.bal
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
//
// WSO2 Inc. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/log;
import ballerinax/microsoft.excel;

Expand All @@ -19,7 +35,7 @@ excel:ExcelConfiguration configuration = {
excel:Client excelClient = check new (configuration);

public function main() {
json values = [["a3"], ["c3"], ["aa"]];
json[][] values = [["a3"], ["c3"], ["aa"]];
int columnIndex = 1;

excel:Column|error response = excelClient->createColumn(workbookIdOrPath, "sheetName", "tableName", values,
Expand Down
16 changes: 16 additions & 0 deletions samples/create_row.bal
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
//
// WSO2 Inc. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/log;
import ballerinax/microsoft.excel;

Expand Down
16 changes: 16 additions & 0 deletions samples/delete_chart.bal
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
//
// WSO2 Inc. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/log;
import ballerinax/microsoft.excel;

Expand Down
16 changes: 16 additions & 0 deletions samples/delete_column.bal
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
//
// WSO2 Inc. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/log;
import ballerinax/microsoft.excel;

Expand Down
16 changes: 16 additions & 0 deletions samples/delete_row.bal
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
//
// WSO2 Inc. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/log;
import ballerinax/microsoft.excel;

Expand Down
16 changes: 16 additions & 0 deletions samples/delete_table.bal
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
//
// WSO2 Inc. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/log;
import ballerinax/microsoft.excel;

Expand Down
16 changes: 16 additions & 0 deletions samples/delete_worksheet.bal
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
//
// WSO2 Inc. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/log;
import ballerinax/microsoft.excel;

Expand Down
Loading