我目前在WordPress中使用PHPSpreadsheet。在本地一切都很好,但是当我将其传输到服务器时,我的电子表格根本无法工作。单击我的“生成excel”按钮时,它会给我提供一系列字符。
我尝试了许多解决方案,但仍然无法正常工作,并显示了一系列未知字符。
这是我在PHPSpreadsheet中的代码
// Initialize context
const context = React.createContext({ name: "" });
/**
* My provider component which has it's own state
* for updating existing context.
*/
const MyProvider = ({ children }) => {
const [state, setState] = React.useState({ name: "" });
return (
<context.Provider value={state}>
<input
value={state.name}
onChange={({ target }) => {
console.log(target.value);
setState({ name: target.value });
}}
/>
{children}
</context.Provider>
);
};
/**
* Context to consume existing parent component context
*/
const MyConsumer = ({ children }) => {
return <context.Consumer>{ctx => <MyComponent {...ctx} />}</context.Consumer>;
};
/**
* provide values as props to your component with lifecycle-methods.
*/
const MyComponent = ({ name }) => {
const [fetchResult, setResult] = React.useState({});
React.useEffect(() => {
console.log("child updated with name: ", name);
/**
* Fetch some data and set it to local state
*/
const mockFetchResult = {
title: name + `\n${Math.random() * 1024}` // Dummy example to get some random data
};
setResult(mockFetchResult);
}, [name]);
return <p>{fetchResult.title}</p>;
};