question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: s.t.match is not a function

See original GitHub issue

I’m using ‘Excel Export with custom cells style’ example and adding dynamic content. When I’m using your example then excelsheet is downloading with correct data but when I’m passing dynamic data then it’s showing error

TypeError: s.t.match is not a function

If I restart my server then many times this error not showing but data also not fetch in excelsheet after download

Sample code is here

import React, {Component} from 'react';
import ReactExport from 'react-data-export';
import _ from 'underscore'

const ExcelFile = ReactExport.ExcelFile;
const ExcelSheet = ReactExport.ExcelFile.ExcelSheet;

class App extends Component {
	constructor(props) {
		super(props);

		this.state = {
			multiDataSet: []
		}
	}

	componentDidMount() {
		this.callFakeApi()
	}

	callFakeApi() {
		fetch('https://jsonplaceholder.typicode.com/posts')
		.then(response => response.json())
		.then(json => {
			console.log(json)
			this.convertDataFormat(json)
		})
	}

	convertDataFormat(json) {
		const jsonHeader = _.keys(json[0])
		const data = json.map((obj, i) => {
			const array = []
			if (i % 2 === 0) {
				var style = {fill: {patternType: "solid", fgColor: {rgb: "FFFF0000"}}}
			} else {
				var style = {}
			}
			jsonHeader.map((columnName) => {
				array.push({value: obj[columnName], style})
			})
			return array
		})
		const multiDataSet = [{columns: jsonHeader, data: data}]
		console.log(multiDataSet)
		this.setState({
			multiDataSet
		})
	}

	render() {
		return (
			<div>
				<ExcelFile element={<button>Download Data With Styles</button>}>
					<ExcelSheet dataSet={this.state.multiDataSet} name="Organization"/>
				</ExcelFile>
			</div>
		);
	}
}

export default App

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
minhtd1981commented, Jun 12, 2018

Hi @securedeveloper,

I’d like to contribute a little bit on this project. This error occurred when s.t is not a string for instance a number.

If you are using dataSet, getCell() should be modified a little bit } else if (typeof v === ‘object’) { cell.v = v.value; cell.s = v.style; if (typeof v === ‘number’) cell.t = ‘n’ }

If you are using data, createSheetData() and excelSheetFromAoA() should be modified a little bit sheetRow.push({ value: … itemValue, style: style }) and } else if (typeof cell.v === ‘object’) { const { value, style } = cell.v; cell.v = value; cell.s = style; if (typeof value === ‘number’) cell.t = ‘n’ } else { so that you can set the style via ExcelColumn.

Thanks,

2reactions
minhtd1981commented, Jun 13, 2018

@gmonte then you cannot use numFmt 😉 @securedeveloper I will try to arrange time to do that

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught TypeError: s.t.match is not a function in react-export ...
Whenever I click on Export button in my frontend,the following error is thrown. Uncaught TypeError: s.t.match is not a function at write_sst_xml ......
Read more >
str.match is not a function | React - EJ 2 Forums | Syncfusion
It appears the function expects a string, but the examples (and my code) are passing a function that returns a ReactElement.
Read more >
TypeError: s.t.match is not a function when trying to use style ...
My reason: Getting above error when trying to use style attribute for column headings. Steps to reproduce:.
Read more >
TypeError: regex match is not a function in JavaScript
The "match is not a function" error occurs when the match method is called on a value that is not of type string....
Read more >
Class: Regexp (Ruby 2.5.1)
A literal string matches itself. Here 'haystack' does not contain the pattern 'needle', so it doesn't match: /needle/.match ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found