Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/xlsx/xform/drawing/base-cell-anchor-xform.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class BaseCellAnchorXform extends BaseXform {
reconcilePicture(model, options) {
if (model && model.rId) {
const rel = options.rels[model.rId];
const match = rel.Target.match(/.*\/media\/(.+[.][a-z]{3,4})/);
const match = rel.Target.match(/.*\/media\/(.+[.][a-zA-Z]{3,4})/);
if (match) {
const name = match[1];
const mediaId = options.mediaIndex[name];
Expand Down
58 changes: 58 additions & 0 deletions spec/integration/workbook/images.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,5 +231,63 @@ describe('Workbook', () => {
expect(Buffer.compare(imageData, image.buffer)).to.equal(0);
});
});

it('image extensions should not be case sensitive', () => {
const wb = new ExcelJS.Workbook();
const ws = wb.addWorksheet('blort');
let wb2;
let ws2;

const imageId1 = wb.addImage({
filename: IMAGE_FILENAME,
extension: 'PNG',
});

const imageId2 = wb.addImage({
filename: IMAGE_FILENAME,
extension: 'JPEG',
});

ws.addImage(imageId1, {
tl: {col: 0.1125, row: 0.4},
ext: {width: 100, height: 100},
});

ws.addImage(imageId2, {
tl: {col: 0.1125, row: 0.4},
br: {col: 2.101046875, row: 3.4},
editAs: 'oneCell',
});

return wb.xlsx
.writeFile(TEST_XLSX_FILE_NAME)
.then(() => {
wb2 = new ExcelJS.Workbook();
return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME);
})
.then(() => {
ws2 = wb2.getWorksheet('blort');
expect(ws2).to.not.be.undefined();

return fsReadFileAsync(IMAGE_FILENAME);
})
.then(imageData => {
const images = ws2.getImages();
expect(images.length).to.equal(2);

const imageDesc1 = images[0];
expect(imageDesc1.range.ext.width).to.equal(100);
expect(imageDesc1.range.ext.height).to.equal(100);
const image1 = wb2.getImage(imageDesc1.imageId);

const imageDesc2 = images[1];
expect(imageDesc2.range.editAs).to.equal('oneCell');

const image2 = wb2.getImage(imageDesc1.imageId);

expect(Buffer.compare(imageData, image1.buffer)).to.equal(0);
expect(Buffer.compare(imageData, image2.buffer)).to.equal(0);
});
});
});
});