I have a build.gradle.kts
file with the following code:
plugins {
kotlin("jvm") version "1.8.0"
application
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.apache.poi:poi-ooxml:5.2.0")
implementation("org.apache.poi:poi:5.2.0")
implementation("com.vortexa.refinery:refinery:master.161")
}
}
But I'm getting an error: untitled:main: Could not find com.vortexa.refinery:refinery:master.161
. Can I clone the repository (https://github.com/VorTECHsa/refinery) and somehow connect it?
To date, what I have done is clone the https://github.com/VorTECHsa/refinery repository. Then, I deleted the test that did not pass when compiled (StringCellParserTest) and performed a Gradle build. After that, I created a new project, added the Refinery JAR files to the libs folder, and added the following code to the build.gradle.kts
file.
dependencies {
testImplementation(kotlin("test"))
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.apache.poi:poi-ooxml:5.2.2")
implementation("org.apache.poi:poi:5.2.2")
implementation("org.junit.jupiter:junit-jupiter:5.8.2")
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.8.1")
implementation("org.assertj:assertj-core:3.19.0")
implementation(fileTree("libs") {
include("*.jar")
})
}
The Main.kt
file contains the following code:
import com.vortexa.refinery.dsl.SheetParserDefinition
import com.vortexa.refinery.dsl.TableParserDefinition
import com.vortexa.refinery.dsl.WorkbookParserDefinition
import com.vortexa.refinery.exceptions.ExceptionManager
import com.vortexa.refinery.WorkbookParser
import org.apache.poi.ss.usermodel.WorkbookFactory
import kotlin.reflect.KClass
import java.io.File
fun main() {
// given
val string = StringHeaderCell("string")
val number = StringHeaderCell("number")
val date = StringHeaderCell("date")
val optionalString = StringHeaderCell("optional_str")
val definition = WorkbookParserDefinition(
spreadsheetParserDefinitions = listOf(
SheetParserDefinition(
sheetNameFilter = { true },
tableDefinitions = listOf(1, 2, 3).map {
TableParserDefinition(
setOf(string, number, date),
setOf(optionalString),
anchor = "table $it"
)
}
)
)
)
val fileName = "test_spreadsheet_multitable_anchors.xlsx"
val file = File(javaClass.classLoader.getResource(fileName)!!.file)
val records = WorkbookFactory.create(file).use {
WorkbookParser(definition, it, exceptionManager, fileName).parse()
}
print(records)
}
But I am having problems with javaClass
(I think it's a basic issue), but I won't know if the library works this way or not until I get the results. What changes should I make to the Main.kt
code to get rid of errors and obtain the results?