Skip to content
Snippets Groups Projects
Commit 869c56db authored by Michael Paffrath's avatar Michael Paffrath
Browse files

1.0.0

- Java code added to access excel data
- C# code added to access excel data
- Python code added to access excel data
parent 0324b414
No related branches found
No related tags found
No related merge requests found
# Java
.idea/
out/
# C Sharp
[Bb]in/
[Oo]bj/
# Python
.vscode/
\ No newline at end of file
File added
File added

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31129.286
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "prototype_csharp", "prototype_csharp\prototype_csharp.csproj", "{FC4A3022-58C4-430D-B12B-E58D412E95AD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FC4A3022-58C4-430D-B12B-E58D412E95AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FC4A3022-58C4-430D-B12B-E58D412E95AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC4A3022-58C4-430D-B12B-E58D412E95AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FC4A3022-58C4-430D-B12B-E58D412E95AD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7B5C9067-968F-42C4-B4B5-138212FE9A05}
EndGlobalSection
EndGlobal
using Microsoft.Office.Interop.Excel;
using System;
using System.IO;
using Range = Microsoft.Office.Interop.Excel.Range;
namespace prototype_csharp
{
class Program
{
static void Main(string[] args)
{
string filename = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), @"../../../../../../")) + "demo.xlsx";
var excelApp = new Microsoft.Office.Interop.Excel.Application();
Workbook workbook = excelApp.Workbooks.Open(filename);
Worksheet worksheet = workbook.Worksheets[1];
Range range = worksheet.UsedRange;
string strResult = (string)(range.Cells[1, 1] as Range).Value2;
Console.WriteLine(strResult);
//Garbage Collector things
workbook.Close();
excelApp.Quit();
}
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<COMReference Include="Microsoft.Office.Interop.Excel">
<WrapperTool>tlbimp</WrapperTool>
<VersionMinor>9</VersionMinor>
<VersionMajor>1</VersionMajor>
<Guid>00020813-0000-0000-c000-000000000046</Guid>
<Lcid>0</Lcid>
<Isolated>false</Isolated>
<EmbedInteropTypes>true</EmbedInteropTypes>
</COMReference>
</ItemGroup>
</Project>
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="poi-ooxml-5.0.0" level="project" />
</component>
</module>
\ No newline at end of file
package com.company;
import org.apache.poi.ss.usermodel.*;
import java.io.File;
public class Main {
public static void main(String[] args) {
// write your code here
try {
File directory = new File(System.getProperty("user.dir"));
String filename = directory.getParent() + "/demo.xlsx";
Workbook workbook = WorkbookFactory.create(new File(filename));
Sheet sheet = workbook.getSheetAt(0);
Row row = sheet.getRow(1);
Cell cell = row.getCell(0);
System.out.println(cell.getStringCellValue());
} catch (Exception ex) {
System.out.println(ex.toString());
}
}
}
import openpyxl
filename = openpyxl.load_workbook('../demo.xlsx')
sheet = filename["Tabelle1"]
print(sheet['A1'].value)
\ No newline at end of file
demo.xlsx 0 → 100644
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment