avoid deleting object, buttons and vba removing - phpspreadsheet

I do not know if it is a bug or not but each time I try to load a XLS template file with objects inside (ie buttons with linked vba)
Phpspreadsheet removes everything and I do not know how to avoid it.
$reader = IOFactory::createReader('Xls');
$reader->setReadDataOnly(false);
$spreadsheet = $reader->load(Storage::disk('template')->path('template.xls'));
$writer = new XlsWriter($spreadsheet);
$writer->save(Storage::disk('template')->path('_test.xls'));
I also tried with $reader->setReadDataOnly(false); but it keeps failing.
For the moment I only try to open a template, named "template.xls" and write it to "_test.xls"
Thank you for reading

PHPSpreadsheet don't support objects, buttons and vba. If you generate some new file all not supported thinks will delete from the excel.

Related

How to create a template dashbord in tableu?

I have a Dashboard in tableau that I want to replicate it with another database that has the same columns/pills!
is it possible to do that?
The best way would be to open the "template dashboard", add the new data source, then go to menu DATA => Replace data source and change the old data source to the new data source.
At this point close the old data source.
The fastest way, but this might not work, is to open the .twb file of the dashboard with Notepad and replace the old database name with the new one...of course something could be broke.
If you have a .twbx file you can open it with WinZip, WinRar, ... and find the .twb file inside.
Possibly you could try 2 Options:
Take a copy of your template. In the Data Source tab, go to Connections -> Edit Connection to point it to the new data source.
In the template, create a new data source. Replace the Old data source with the new one by Data -> Replace Data Source.
For the formulas and filters to reflect on the new data source, make sure the field names and data types are the same as the old data source.
Kindly note: Editing the XML is unsupported by Tableau! Create a copy of your original workbook before attempting any XML editing, as this could potentially corrupt your workbook.

How to create Trailer Record in Flat File using SSIS

I am looking for some help on how to create a trailer record in a flat file using SSIS, I have create a SSIS package that creates a custom header and loads other record from the database into the flat file, it is a fixed width flat file. Now at the end of the file I want to create a Trailer Record along with some static text and Record count. I tried looking on to google but could not get any good example. Any help is much appreciated.
Use a Script Task. Take the file path of the fixed width flat file that you have obtained as a input variable. Once withing the script task use the .Net coding to append the data that you need. I have written a post on it - https://karbimantras.wordpress.com/2016/08/12/adding-record-count-to-flat-file/

How to merge multiple plist files into one?

Just to start, I really have no idea what Im doing. I was given this task for an internship, and am really learning as I go. I have multiple plist files, they consist of around 22 items each, and list values of colors. I need to merge all of these files into one, and am really not sure how to go about it. I have a certain structure I need to go by, and really Im not sure how to go about it. I was told to open the plists in texteditor and then paste all of the raw code into one text file, this doesn't seem to work as I only end up getting the values for the first plist I pasted into the text file. Any help would be nice. Thanks.
Assume your from.plist contains keys 1, 2 and to.plist contains 2, 3
Run this:
/usr/libexec/PlistBuddy -x -c "Merge from.plist" to.plist
to.plist will contain 1, 2, 3
There are a number of ways to handle this. By default a plist is a special form of XML file. If you figure out the syntax you can in fact use a text editor to merge the contents of multiple files together, but you need to make sure you get it right.
A plist file has a specific header for the entire file. You could not just copy/paste multiple plists together because then they would have that header repeated.
The next way to do it is programmatically. If you can figure out the type of outer collection these files contain (probably an array or a dictionary) then you could write a few lines of code that read in each of the plists as arrays, combines them using NSArray code (assuming they contain arrays of colors) and then save the combined array back to a new plist. As vadian says you can also use the NSPropertyListSerialization class. Thats a more general-pupose way of handling plist files, but it's also more complex and harder to figure out.
A third way to do it is in Xcode. If you right-click on a plist file and select "open in Xcode" it should give you Xcode's property list editor. You can then copy and paste the contents of the files together and save the results to a new file.
I figured it out!! First create the structure, or use the template given to you. I suggest opening this template/ structure in Xcode, as it makes it easier to switch between viewing the list as a plist and source code. Open your template as a source code. Then open each of your plists in text editor, and copy and paste the code from your plists into the appropriate area in your templates source code, then you can view it in Xcode as a property list to make sure it's correct. The only thing you have to be careful about here is making sure you are getting no errors. Otherwise this works great!!

How to get the "Created by <name> on <date>" text

So the question is actually simple, but I have no idea how to approach this issue. I know this code is generated by template based on this question:
XCode automatically generated comments?
I want to use the <name> that xcode provides on each mac machine which is unique for it's user, for some types of logs.
EDIT:
This is how the swift template file looks before it's used by Xcode to create my work file:
//
// ___FILENAME___
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
//___COPYRIGHT___
//
Surely, there is no point in parsing it.
The question is: Does anyone knows how I can get this name using swift in my application?
I searched for an answer here/Google but so far no luck.
I don't know how to read the header. But you can do it otherwise.
First if you need the creation-date of a file, you can use the NSFileManager:
var path = "path/to/your/file/"
var fileAttribs:NSDictionary = NSFileManager.defaultManager().attributesOfFileSystemForPath(path, error: nil)!
var creationDate = fileAttribs.objectForKey(NSFileCreationDate)
Also if you need the full username, you can use the function NSFullUserName() or NSUserName(). It should return the same string as __FULLUSERNAME__
var fullUsername = NSFullUserName()
var username = NSUserName()
Sometimes in the iOS Simulator, this username is empty, but in a real app, it should work properly.
That text written at template instantiation time β€” that is, when you create a new Xcode project (or a new file in an existing project using the File > New > File... templates). You can't read the contents of the source file your code was compiled from. (Well, unless you ship that file along with your compiled binary, and read it in like any other text file.)
But that's just text substitution β€” it can be done anywhere in the file, not just in the comment headers. So you could create your own file or project templates, and in the template files, put those substitution macros in code instead of in comments:
let schmoeWhoCreatedThisFile = "___FULLUSERNAME___"
Here's a tutorial found in a couple seconds of web searching that has the full details on creating templates and the substitution macros you can use in them.
Remember, substitution happens when you create a new file or project β€” if you're looking for who made the latest change to your source file or who built the app that shipped to your customers, you're barking up the wrong tree. Some of those sorts of things you can do with source control; others are more a matter of (human-defined, human-executed) policy for you or or your organization.

Filemaker: exporting a PLIST (for iOS)

I have a database which I want to export as an iOS compatible PLIST.
The work around I have come up with is to create a calculated field which adds the tagged padding and header and creates a report using these fields. I then export the preview of the report as a PDF, open the PDF in Acrobat Reader, select all text, copy and paste into XCode which recognises the PLIST format and all works as expected.
Is there a better way of doing this? (This seems a really convoluted way of doing things, high chance of error, etc.) The Export as XML option looks promising but I can't seem to join the dots.
Two ways that I can think of to do what you're trying to do. The most elegant way is probably the XML with XSLT export which you suggest. If you don't already know XSLT, though, you might try the following -- it sounds like with the calculated XML line you've already created, like this would be a simple change to your database:
Create a single new global field, say outputXML
Create a script, say plistCreator
In the plistCreator script:
Set outputXML to ""
Go to the first record you want to export
Loop through every record putting your calculated XML line into outputXML (set field outputXML to outputXML & ΒΆ & calculatedXMLLine)
Go to next record, exit after last
Export Field Contents (note that this is a different command than Export) for outputXML
The cleanest solution is to use the export XML with an XSLT for transforming the output. You'll need to know a little XSLT to do this, or at least be able to customize the examples from FileMaker.

Resources