Skip to main content
New
Stack Overflow Jobs powered by Indeed: A job site that puts thousands of tech jobs at your fingertips (U.S. only). Search jobs
13 votes
Accepted

Generate xlsx file from Apex

You're not going to be able to use XLSX at all. It's based on the Office Open XML standards from Microsoft. Basically, it's a set of XML files contained in a ZIP file, of which we have no native means ...
sfdcfox's user avatar
  • 494k
12 votes

Generate xlsx file from Apex

I know the question has already been answered but to anyone who stumbles upon here looking for other options, I found a solution that generates an actual .xlsx file using only Apex. Take note though ...
Raymar Monte's user avatar
9 votes

bulk api text/csv CRLF error

change the Request body of Job Creation as follows. { "operation" : "insert", "object" : "Product2", "contentType" : "CSV", "lineEnding" : "LF" } It worked for me.Also ensure that the ...
kiran Nath's user avatar
9 votes

Most robust way to parse CSV file via Apex code

Update: Winter '23 With Winter '23 there is now the Developer Preview of directly using DataWeave in Apex - See Use DataWeave in Apex to Enable Data Transformation to Different Formats (Developer ...
Daniel Ballinger's user avatar
7 votes
Accepted

Handle Extra "\r\n" new line in CSV from code level

Basically, you should call a replaceAll beforehand: contents = contents.replaceAll('(\r\n|\r)','\n'); This code normalizes CRLF and CR to use just LF. Note that CSV may be in any of those three ...
sfdcfox's user avatar
  • 494k
6 votes
Accepted

Making a string in apex class bold?

That's not how CSV files work. Comma Separated Values means that the file contains tabular data values in plain text. Values only. No formatting. Note that the below solution is the only way to ...
Adrian Larson's user avatar
  • 150k
6 votes
Accepted

Loop through comma separated values in Visual Flow

Sure you can. Roughly the steps would go like this. Create a screen element with a long text area input field. Link it to a decision element to see if the field is empty. If it's not (shouldn't be ...
Kasper's user avatar
  • 2,907
6 votes
Accepted

Parse JSON to CSV and vice versa

Here's a very simple CSV parsing demo from papaparse: import { LightningElement } from 'lwc'; import { loadScript } from 'lightning/platformResourceLoader'; import PAPA from '@salesforce/resourceUrl/...
sfdcfox's user avatar
  • 494k
6 votes

How to parse a CSV file into JSON using APEX?

Inspired by this code, fixed up by Daniel Ballinger, I wrote this version, which returns a list of Maps. It turns out that in order to have decent performance, you have to write it in a really ...
sfdcfox's user avatar
  • 494k
5 votes
Accepted

VisualForce MultiLine UTF-8 CSV

OK, I have a plausible solution for Excel for Mac users. First, the options that I considered but rejected: Windows-1252 encoding - Doesn't support Asian languages UTF-16LE encoding - Creates user ...
cropredy's user avatar
  • 71.8k
5 votes
Accepted

Read through small CSV file returns Regex too complicated

The regex too complicated error occurs when you reach 1,000,000 input sequences, which can occur even on incredibly small strings. For example, accord to the knowledge article: Pattern pat = Pattern....
sfdcfox's user avatar
  • 494k
4 votes

Email Attachment (CSV) Issue

This appears to be classic Microsoft Excel behavior when confronted with UTF-8 text. Excel likes to interpret a valid UTF-8 bytestream as if it were encoded in Windows Codepage 1252 or other encodings....
David Reed's user avatar
  • 93.1k
4 votes
Accepted

Dynamic csv generation for a dynamic soql query in apex

If possible, construct the data client-side with something like papaparse. This is much less error-prone and will run a lot faster besides. If you're insisting on doing this in Apex, consider using an ...
sfdcfox's user avatar
  • 494k
4 votes
Accepted

Create CSV from SOQL query

This could be a misinterpretation of the UI. You need to click on the download icon
cropredy's user avatar
  • 71.8k
4 votes
Accepted

SSJS Automation Studio - Read imported CSV file

In order to do this, you will need to import that file into a Data Extension first. None of Marketing Cloud's scripting languages (SSJS, AMPscript, SQL, or GTL) can touch the SFTP or anything on it. ...
Gortonington's user avatar
  • 30.6k
3 votes
Accepted

Not Able to parse date filed from CSV file, It is giving Illegal assignment from String to Date

You have to parse the string as a date using Date.valueOf() to make it a date before you can assign it to a date field. I would use SobjecType.getDescribe().fields.getMap() to get a list of fields, ...
John Towers's user avatar
  • 3,873
3 votes

Dataloader csv file size or record count limit?

I can't flag this question as a duplicate, but this question has already been asked on Stack Overflow. So I'll just quote the Data Loader Guide and @eyescream (emphasis mine): Use Data Loader when: ...
Adrian Larson's user avatar
  • 150k
3 votes

Empty Key/ Random string on export?

If anyone is still looking for this answer A query on EntityDefinition will return two options for "id". Use the Durableid.
Sean's user avatar
  • 31
3 votes

Empty Key/ Random string on export?

This is what is referred to as the "Empty Key". It will be 15 0's followed by the 3 character suffix to make it case insensitive. They are used to represent null values in a Data Export. I've blogged ...
Daniel Ballinger's user avatar
3 votes
Accepted

Visualforce Content Type text/csv#filename.csv Renders on One Row

You need to add a few newlines: <apex:page standardController="Custom_Object__c" cache="true" contentType="text/csv#filename.csv" language="en-US"> Col A","Col B","Col C","Col D","Col E", <...
sfdcfox's user avatar
  • 494k
3 votes

Export Visualforce CSV with UTF-8 (With BOM) format

You can make this work by including the BOM at the start of the VisualForce page. In the VF page on the first line I have (the strange use of outputText is something I've inherited from an existing ...
andynormancx's user avatar
3 votes
Accepted

Broken CSV exports

Maybe this is an issue with text delimeters of microsoft office? When you import .csv Files where in some columns there could be values that inherit delimeters like " in odd-times, it may be that ...
Johannes Schapdick's user avatar
3 votes

bulk api text/csv CRLF error

The error message is pointing to the issue: you've declared to Salesforce that you're sending data where lines are delimited using CRLF (the standard on Windows), but your data doesn't conform to that ...
David Reed's user avatar
  • 93.1k
3 votes
Accepted

Formatting Excel Column from Apex

This is an locale + Excel issue. You cannot apply formatting in a CSV file as such. You're outputting dates in DD/MM/YY format. Excel is reading them in MM/DD/YY. If you notice which dates are and ...
David Reed's user avatar
  • 93.1k
3 votes

Data Extension CSV export not working correctly

Using the example text from above, I was able to successfully import into a test data extension by using a delimiter of |. I was also able to successfully import by adding quotations to the field as ...
Travis's user avatar
  • 150
3 votes
Accepted

Dataloader = CSV = Numbers = Scientific Notation

If you are using Dataloader, I believe, that's the best option (You are already doing it). DON'T open the file at all. You can try ETL tools, such as Informatica , Jitterbit etc
Amit Sahu's user avatar
  • 141
3 votes

CSV File Date Issue

I am assuming you have a DateTime field. You can use format() method on DateTime field, but if you need to do formatting on a Date field, you can convert Date to DateTime and use again format() ...
vitaliaventel's user avatar
3 votes

How to parse large size csv file content into custom object in Salesforce?

No, Apex won't handle 1GB. A single string can be at most heap size in length (12MB for Batch Apex). Since you're using LWC, process the file client-side and pass the data in chunks to Apex. If you ...
sfdcfox's user avatar
  • 494k
3 votes
Accepted

How To Check For Duplicates Using SOQL and Apex

If "Name" is a unique field for these records, you can use the Database class with the insert method. insert(recordsToInsert, dmlOptions) You can put this in a try-catch block and after ...
azimut3's user avatar
  • 120

Only top scored, non community-wiki answers of a minimum length are eligible