All,
Going through several different posts in the community on the topic, I believe I know the answer to my question. However, I will still go ahead and summarize the issue and see if anyone else has gone down this path.
Problem Statement: Generate an Excel Workbook in a previously accepted and recognized template
Not for Debate : Why is Excel the chosen format of output
In going through the following posts :
- https://community.jmp.com/t5/Discussions/Excel-Table-Formatting/m-p/33650#M19957
- https://community.jmp.com/t5/Martin-Demel-s-Blog/JMP-and-Excel-A-Never-ending-story-Part-2-cont/ba-p/35941 (and all the relevant blog posts on topic)
- https://community.jmp.com/t5/Discovery-Summit-2016/Working-With-Excel-the-Advanced-Edition/ta-p/23969
Understandably a lot of focus is on how to import and export data between Excel and JMP. However, none of them really speak about preserving/customizing the format of the data that is exported from JMP and Excel. Whether we like it or not, Excel is still going to be around and there will be a continuous need for presenting our results via Excel (least of which is every user cannot have a JMP license).
Given that background, I have an Excel template and I would like to edit some data in the Excel template using JSL preferably. This is the last step of a really large application that I have in JMP. Ideally, all I need is for JMP to edit the data in the template and save the workbook. Unfortunately, as you can expect the minute I open the file in JMP, the formatting goes for a toss and leaves me with a garbled format which is not really presentable to the user.
So,
1. Is there a way using JSL not VBA to preserve the formatting in an Excel Template and edit the data in the file ?
2. Assuming the answer to my previous question is "No", I have gone down the path of using "XLConnect" package in R. However, that is also running into troubles. I don't expect the JMP community to address questions on why the R package is not yielding the results. Should anyone be interested in helping, the R code is provided below. Also attached is an example template that I am experimenting on
# Clear Console and screen
cat("\014") # Clear Console
rm(list = ls(all = TRUE)) # Clear Workspace
options(java.parameters = "- Xmx1024m")
# Load desired packages
suppressPackageStartupMessages(library(XLConnect))
# Define FilePaths
FolderPath <- "C:\\Users\\Temp\\Desktop"
TemplateFilePath <- paste(FolderPath, "LoanTemplate.xlsx", sep = "\\")
OutputFilePath <- paste(FolderPath, "MyLoan.xlsx", sep = "\\")
OutputFilePath1 <- paste(FolderPath, "MyLoan1.xlsx", sep = "\\")
OutputFilePath2 <- paste(FolderPath, "MyLoan2.xlsx", sep = "\\")
# Read Data
TemplateData <- readWorksheetFromFile(TemplateFilePath, sheet = 'Loan Schedule', header = T)
MyData <- TemplateData
MyData[[4]][2] <- 10000
# Set Style Action
setStyleAction(wb, XLC$"STYLE_ACTION.NONE")
# Trial 1
writeWorksheet(OutputFilePath, MyData, 'Loan Schedule', styleAction = XLC$STYLE_ACTION.XLCONNECT, clearSheets = TRUE)
# Trial 2
writeWorksheetToFile(OutputFilePath1, MyData, 'Loan Schedule', styleAction = XLC$STYLE_ACTION.XLCONNECT, clearSheets = FALSE)
#Trial 3
writeWorksheetToFile(OutputFilePath2, MyData, 'Loan Schedule')